translator: add test for when
This commit is contained in:
@@ -7,7 +7,7 @@ class ByteArray(var size: Int) {
|
|||||||
val data: Int
|
val data: Int
|
||||||
|
|
||||||
/** Returns the number of elements in the array. */
|
/** Returns the number of elements in the array. */
|
||||||
//val size: Int
|
//size: Int
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.data = malloc_array(this.size)
|
this.data = malloc_array(this.size)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class IntArray(var size: Int) {
|
|||||||
val data: Int
|
val data: Int
|
||||||
|
|
||||||
/** Returns the number of elements in the array. */
|
/** Returns the number of elements in the array. */
|
||||||
//val size: Int
|
//size: Int
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.data = malloc_array(4 * this.size)
|
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(55555) == 50
|
||||||
when_expression_1_Int(345626) == 100
|
when_expression_1_Int(345626) == 100
|
||||||
when_expression_1_Int(756754) == 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
|
||||||
|
|||||||
@@ -6,3 +6,17 @@ fun when_expression_1(x: Int): Int {
|
|||||||
}
|
}
|
||||||
return z
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user