translator: add test for when

This commit is contained in:
Alexey Stepanov
2016-08-08 12:03:59 +03:00
parent a6849214c3
commit d598eb48bb
4 changed files with 19 additions and 2 deletions
@@ -7,7 +7,7 @@ class ByteArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//val size: Int
//size: Int
init {
this.data = malloc_array(this.size)
@@ -6,7 +6,7 @@ class IntArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//val size: Int
//size: Int
init {
this.data = malloc_array(4 * this.size)
@@ -2,3 +2,6 @@ when_expression_1_Int(21234) == 20
when_expression_1_Int(55555) == 50
when_expression_1_Int(345626) == 100
when_expression_1_Int(756754) == 100
when_expression_2_Byte(0) == 100
when_expression_2_Byte(5) == 105
when_expression_2_Byte(155) == 199
@@ -5,4 +5,18 @@ fun when_expression_1(x: Int): Int {
else -> 100
}
return z
}
fun when_expression_2 (value: Byte): Int {
val result = when (value) {
0.toByte() -> 100
1.toByte() -> 101
2.toByte() -> 102
3.toByte() -> 103
4.toByte() -> 104
5.toByte() -> 105
else -> 199
}
return result
}