diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 82ec63facbb..588b6ca50d3 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -681,6 +681,11 @@ task scope1(type: RunKonanTest) { source = "codegen/dataflow/scope1.kt" } +task uninitialized_val(type: RunKonanTest) { + goldValue = "1\n2\n" + source = "codegen/dataflow/uninitialized_val.kt" +} + task try1(type: RunKonanTest) { goldValue = "5\n" source = "codegen/try/try1.kt" @@ -712,7 +717,6 @@ task break_continue(type: RunKonanTest) { } task break1(type: RunKonanTest) { - disabled = true goldValue = "Body\nDone\n" source = "codegen/controlflow/break1.kt" } @@ -842,3 +846,14 @@ task initializers2(type: RunKonanTest) { "globalValue3\n" source = "runtime/basic/initializers2.kt" } + +task initializers3(type: RunKonanTest) { + goldValue = "42\n" + source = "runtime/basic/initializers3.kt" +} + +task expression_as_statement(type: RunKonanTest) { + disabled = true + goldValue = "Ok\n" + source = "codegen/basics/expression_as_statement.kt" +} \ No newline at end of file diff --git a/backend.native/tests/codegen/basics/expression_as_statement.kt b/backend.native/tests/codegen/basics/expression_as_statement.kt new file mode 100644 index 00000000000..562d4fb485f --- /dev/null +++ b/backend.native/tests/codegen/basics/expression_as_statement.kt @@ -0,0 +1,14 @@ +fun foo() { + Any() as String +} + +fun main(args: Array) { + try { + foo() + } catch (e: Throwable) { + println("Ok") + return + } + + println("Fail") +} \ No newline at end of file diff --git a/backend.native/tests/codegen/dataflow/uninitialized_val.kt b/backend.native/tests/codegen/dataflow/uninitialized_val.kt new file mode 100644 index 00000000000..bc963690258 --- /dev/null +++ b/backend.native/tests/codegen/dataflow/uninitialized_val.kt @@ -0,0 +1,17 @@ +fun foo(b: Boolean): Int { + val x: Int + if (b) { + x = 1 + } else { + x = 2 + } + + return x +} + +fun main(args: Array) { + val uninitializedUnused: Int + + println(foo(true)) + println(foo(false)) +} \ No newline at end of file diff --git a/backend.native/tests/runtime/basic/initializers3.kt b/backend.native/tests/runtime/basic/initializers3.kt new file mode 100644 index 00000000000..b2b93283752 --- /dev/null +++ b/backend.native/tests/runtime/basic/initializers3.kt @@ -0,0 +1,7 @@ +class Foo(val bar: Int) + +var x = Foo(42) + +fun main(args: Array) { + println(x.bar) +} \ No newline at end of file