diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 4575e54e8cc..c9bcc050469 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -769,7 +769,6 @@ task initializers4(type: RunKonanTest) { } task expression_as_statement(type: RunKonanTest) { - disabled = true goldValue = "Ok\n" source = "codegen/basics/expression_as_statement.kt" } @@ -792,4 +791,24 @@ task memory_var3(type: RunKonanTest) { task memory_var4(type: RunKonanTest) { disabled = true source = "runtime/memory/var4.kt" +} + +task unit1(type: RunKonanTest) { + goldValue = "First\nkotlin.Unit\n" + source = "codegen/basics/unit1.kt" +} + +task unit2(type: RunKonanTest) { + goldValue = "kotlin.Unit\n" + source = "codegen/basics/unit2.kt" +} + +task unit3(type: RunKonanTest) { + goldValue = "kotlin.Unit\n" + source = "codegen/basics/unit3.kt" +} + +task unit4(type: RunKonanTest) { + goldValue = "Done\n" + source = "codegen/basics/unit4.kt" } \ No newline at end of file diff --git a/backend.native/tests/codegen/basics/unit1.kt b/backend.native/tests/codegen/basics/unit1.kt new file mode 100644 index 00000000000..689c239a79a --- /dev/null +++ b/backend.native/tests/codegen/basics/unit1.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + println(println("First").toString()) +} \ No newline at end of file diff --git a/backend.native/tests/codegen/basics/unit2.kt b/backend.native/tests/codegen/basics/unit2.kt new file mode 100644 index 00000000000..67f7efaabde --- /dev/null +++ b/backend.native/tests/codegen/basics/unit2.kt @@ -0,0 +1,8 @@ +fun main(args: Array) { + val x = foo() + println(x.toString()) +} + +fun foo() { + return Unit +} \ No newline at end of file diff --git a/backend.native/tests/codegen/basics/unit3.kt b/backend.native/tests/codegen/basics/unit3.kt new file mode 100644 index 00000000000..5a2a673a50c --- /dev/null +++ b/backend.native/tests/codegen/basics/unit3.kt @@ -0,0 +1,7 @@ +fun main(args: Array) { + foo(Unit) +} + +fun foo(x: Any) { + println(x.toString()) +} \ No newline at end of file diff --git a/backend.native/tests/codegen/basics/unit4.kt b/backend.native/tests/codegen/basics/unit4.kt new file mode 100644 index 00000000000..6ca7f6ee4e8 --- /dev/null +++ b/backend.native/tests/codegen/basics/unit4.kt @@ -0,0 +1,37 @@ +fun main(args: Array) { + for (x in 0 .. 8) { + foo(x, Unit) + } + println("Done") +} + +var global = 42 + +fun foo(x: Int, unit: Unit) { + var local = 5 + val y: Unit = when (x) { + 0 -> {} + 1 -> local = 6 + 2 -> global = 43 + 3 -> unit + 4 -> Unit + 5 -> bar() + 6 -> return + 7 -> { + 5 + bar() + } + 8 -> { + val z: Any = Unit + z as Unit + } + else -> throw Error() + } + + if (y !== Unit) { + println("Fail at x = $x") + } +} + +fun bar() { +} \ No newline at end of file