diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index c6a231429b3..3fe2a4160a1 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -2680,6 +2680,10 @@ task initializers6(type: KonanLocalTest) { source = "runtime/basic/initializers6.kt" } +task initializers7(type: KonanLocalTest) { + source = "runtime/basic/initializers7.kt" +} + task expression_as_statement(type: KonanLocalTest) { expectedFail = (project.testTarget == 'wasm32') // uses exceptions. goldValue = "Ok\n" diff --git a/backend.native/tests/runtime/basic/initializers7.kt b/backend.native/tests/runtime/basic/initializers7.kt new file mode 100644 index 00000000000..2e4971830ba --- /dev/null +++ b/backend.native/tests/runtime/basic/initializers7.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package runtime.basic.initializers7 + +import kotlin.test.* + +import kotlin.random.Random + +object A { + val a1 = Random.nextInt(100) + val a2 = Random.nextInt(100) +} + +object B { + val b1 = A.a2 + val b2 = C.c1 +} + +object C { + val c1 = Random.nextInt(100) + val c2 = A.a1 + val c3 = B.b1 + val c4 = B.b2 +} + +@Test fun runTest() { + assertEquals(A.a1, C.c2) + assertEquals(A.a2, C.c3) + assertEquals(C.c1, C.c4) +}