[K/N] Migrate some cinterop tests to new test infra
^KT-61259
diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle
index 9650c0c..76b10c8 100644
--- a/kotlin-native/backend.native/tests/build.gradle
+++ b/kotlin-native/backend.native/tests/build.gradle
@@ -313,46 +313,6 @@
expectedExitStatus = 42
}
-standaloneTest('enumEquals') {
- useGoldenData = true
- source = "runtime/basic/enum_equals.kt"
- flags = ['-XXLanguage:-ProhibitComparisonOfIncompatibleEnums', '-e', 'runtime.basic.enum_equals.main']
-}
-
-standaloneTest("cleaner_basic") {
- enabled = !isNoopGC
- source = "runtime/basic/cleaner_basic.kt"
- flags = ['-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
-}
-
-standaloneTest("collect_reference_field_values") {
- enabled = !isNoopGC
- source = "runtime/basic/collectReferenceFieldValues.kt"
- flags = ['-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
-}
-
-standaloneTest("cleaner_workers") {
- enabled = !isNoopGC
- source = "runtime/basic/cleaner_workers.kt"
- flags = ['-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
-}
-
-standaloneTest("cleaner_in_main_with_checker") {
- enabled = !isNoopGC
- source = "runtime/basic/cleaner_in_main_with_checker.kt"
- useGoldenData = true
-}
-
-standaloneTest("cleaner_in_main_without_checker") {
- source = "runtime/basic/cleaner_in_main_without_checker.kt"
- useGoldenData = true
-}
-
-standaloneTest("cleaner_leak_without_checker") {
- source = "runtime/basic/cleaner_leak_without_checker.kt"
- useGoldenData = true
-}
-
standaloneTest("cleaner_leak_with_checker") {
enabled = !isNoopGC
source = "runtime/basic/cleaner_leak_with_checker.kt"
@@ -360,10 +320,6 @@
outputChecker = { s -> (s =~ /Cleaner (0x)?[0-9a-fA-F]+ was disposed during program exit/).find() }
}
-standaloneTest("cleaner_in_tls_main_without_checker") {
- source = "runtime/basic/cleaner_in_tls_main_without_checker.kt"
-}
-
standaloneTest("cleaner_in_tls_main_with_checker") {
enabled = !isNoopGC
source = "runtime/basic/cleaner_in_tls_main_with_checker.kt"
@@ -371,12 +327,6 @@
outputChecker = { s -> (s =~ /Cleaner (0x)?[0-9a-fA-F]+ was disposed during program exit/).find() }
}
-standaloneTest("cleaner_in_tls_worker") {
- enabled = !isNoopGC
- source = "runtime/basic/cleaner_in_tls_worker.kt"
- flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
-}
-
standaloneTest('logging') {
outputChecker = { out ->
out.toLowerCase().contains("[logging]") && // loging reports configured log levels on info level
@@ -691,41 +641,6 @@
lib = "link/klib_name/lib.kt"
}
-tasks.register("throw0", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/throw0.kt"
-}
-
-tasks.register("statements0", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/statements0.kt"
-}
-
-tasks.register("interface0", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/interface0.kt"
-}
-
-tasks.register("catch1", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/exceptions/catch1.kt"
-}
-
-tasks.register("catch2", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/exceptions/catch2.kt"
-}
-
-tasks.register("catch7", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/exceptions/catch7.kt"
-}
-
-tasks.register("extend_exception", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/exceptions/extend0.kt"
-}
-
standaloneTest("check_stacktrace_format_coresymbolication") {
disabled = !PlatformInfo.supportsCoreSymbolication(project) || project.globalTestArgs.contains('-opt')
flags = ['-g', '-Xbinary=sourceInfoType=coresymbolication']
@@ -849,14 +764,6 @@
outputChecker = { s -> s.contains("Uncaught Kotlin exception:") && s.contains("FAIL") && !s.contains("in kotlin main") }
}
-tasks.register("rethrow_exception", KonanLocalTest) {
- source = "runtime/exceptions/rethrow.kt"
-}
-
-tasks.register("throw_from_catch", KonanLocalTest) {
- source = "runtime/exceptions/throw_from_catch.kt"
-}
-
standaloneTest("terminate") {
expectedExitStatusChecker = { it != 0 }
source = "runtime/exceptions/terminate.kt"
@@ -892,52 +799,10 @@
source = "runtime/basic/assert_failed.kt"
}
-tasks.register("initializers0", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/initializers0.kt"
-}
-
-
-tasks.register("initializers1", KonanLocalTest) {
- useGoldenData = true
- enabled = false
- source = "runtime/basic/initializers1.kt"
-}
-
-
-standaloneTest("initializers2") {
- useGoldenData = true
-
- source = "runtime/basic/initializers2.kt"
-}
-
-tasks.register("initializers3", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/initializers3.kt"
-}
-
-tasks.register("initializers4", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/initializers4.kt"
-}
-
-tasks.register("initializers5", KonanLocalTest) {
- useGoldenData = true
- source = "runtime/basic/initializers5.kt"
-}
-
tasks.register("initializers6", KonanLocalTest) {
source = "runtime/basic/initializers6.kt"
}
-tasks.register("initializers7", KonanLocalTest) {
- source = "runtime/basic/initializers7.kt"
-}
-
-tasks.register("initializers8", KonanLocalTest) {
- source = "runtime/basic/initializers8.kt"
-}
-
tasks.register("memory_var1", KonanLocalTest) {
source = "runtime/memory/var1.kt"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt
index be422ca..b3a3e11 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt
+++ b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt
@@ -20,4 +20,6 @@
Platform.isCleanersLeakCheckerActive = true
// Make sure cleaner is initialized.
assertNotNull(globalCleaner)
+
+
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/enum_equals.kt b/kotlin-native/backend.native/tests/runtime/basic/enum_equals.kt
deleted file mode 100644
index b5db82a..0000000
--- a/kotlin-native/backend.native/tests/runtime/basic/enum_equals.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2010-2018 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.enum_equals
-
-import kotlin.test.*
-
-enum class EnumA {
- A, B
-}
-
-enum class EnumB {
- B
-}
-
-fun main() {
- println(EnumA.A == EnumA.A)
- println(EnumA.A == EnumA.B)
- println(EnumA.A == EnumB.B)
-}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/basic/enum_equals.out b/kotlin-native/backend.native/tests/runtime/basic/enum_equals.out
deleted file mode 100644
index 36bc613..0000000
--- a/kotlin-native/backend.native/tests/runtime/basic/enum_equals.out
+++ /dev/null
@@ -1,3 +0,0 @@
-true
-false
-false
diff --git a/kotlin-native/backend.native/tests/runtime/basic/throw0.out b/kotlin-native/backend.native/tests/runtime/basic/throw0.out
deleted file mode 100644
index a965a70..0000000
--- a/kotlin-native/backend.native/tests/runtime/basic/throw0.out
+++ /dev/null
@@ -1 +0,0 @@
-Done
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/extend0.out b/kotlin-native/backend.native/tests/runtime/exceptions/extend0.out
deleted file mode 100644
index d86bac9..0000000
--- a/kotlin-native/backend.native/tests/runtime/exceptions/extend0.out
+++ /dev/null
@@ -1 +0,0 @@
-OK
diff --git a/kotlin-native/backend.native/tests/runtime/basic/statements0.kt b/native/native.tests/testData/codegen/basics/statements0.kt
similarity index 86%
rename from kotlin-native/backend.native/tests/runtime/basic/statements0.kt
rename to native/native.tests/testData/codegen/basics/statements0.kt
index 8011155..ac374c3 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/statements0.kt
+++ b/native/native.tests/testData/codegen/basics/statements0.kt
@@ -2,8 +2,7 @@
* Copyright 2010-2018 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.statements0
+// OUTPUT_DATA_FILE: statements0.out
import kotlin.test.*
@@ -36,7 +35,9 @@
println(foo.i)
}
-@Test fun runTest() {
+fun box(): String {
simple()
fields()
-}
\ No newline at end of file
+
+ return "OK"
+}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/statements0.out b/native/native.tests/testData/codegen/basics/statements0.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/statements0.out
rename to native/native.tests/testData/codegen/basics/statements0.out
diff --git a/native/native.tests/testData/codegen/enum/enum_equals.kt b/native/native.tests/testData/codegen/enum/enum_equals.kt
new file mode 100644
index 0000000..eaf83fe
--- /dev/null
+++ b/native/native.tests/testData/codegen/enum/enum_equals.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2010-2018 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.
+ */
+// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
+
+import kotlin.test.*
+
+enum class EnumA {
+ A, B
+}
+
+enum class EnumB {
+ B
+}
+
+fun box(): String {
+ if (!(EnumA.A == EnumA.A))
+ return "FAIL: A must equal A"
+ if (EnumA.A == EnumA.B)
+ return "FAIL: A.A must not equal A.B"
+ if (EnumA.A == EnumB.B)
+ return "FAIL: A.A must not equal B.B"
+
+ return "OK"
+}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/catch1.kt b/native/native.tests/testData/codegen/exceptions/catch1.kt
similarity index 85%
rename from kotlin-native/backend.native/tests/runtime/exceptions/catch1.kt
rename to native/native.tests/testData/codegen/exceptions/catch1.kt
index e22562c..5b58c8a 100644
--- a/kotlin-native/backend.native/tests/runtime/exceptions/catch1.kt
+++ b/native/native.tests/testData/codegen/exceptions/catch1.kt
@@ -2,12 +2,11 @@
* Copyright 2010-2018 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.exceptions.catch1
+// OUTPUT_DATA_FILE: catch1.out
import kotlin.test.*
-@Test fun runTest() {
+fun box(): String {
try {
println("Before")
foo()
@@ -17,6 +16,7 @@
}
println("Done")
+ return "OK"
}
fun foo() {
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/catch1.out b/native/native.tests/testData/codegen/exceptions/catch1.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/exceptions/catch1.out
rename to native/native.tests/testData/codegen/exceptions/catch1.out
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/catch2.kt b/native/native.tests/testData/codegen/exceptions/catch2.kt
similarity index 88%
rename from kotlin-native/backend.native/tests/runtime/exceptions/catch2.kt
rename to native/native.tests/testData/codegen/exceptions/catch2.kt
index 5eee69f..5463381 100644
--- a/kotlin-native/backend.native/tests/runtime/exceptions/catch2.kt
+++ b/native/native.tests/testData/codegen/exceptions/catch2.kt
@@ -2,12 +2,11 @@
* Copyright 2010-2018 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.exceptions.catch2
+// OUTPUT_DATA_FILE: catch2.out
import kotlin.test.*
-@Test fun runTest() {
+fun box(): String {
try {
println("Before")
foo()
@@ -21,6 +20,7 @@
}
println("Done")
+ return "OK"
}
fun foo() {
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/catch2.out b/native/native.tests/testData/codegen/exceptions/catch2.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/exceptions/catch2.out
rename to native/native.tests/testData/codegen/exceptions/catch2.out
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/catch7.kt b/native/native.tests/testData/codegen/exceptions/catch7.kt
similarity index 84%
rename from kotlin-native/backend.native/tests/runtime/exceptions/catch7.kt
rename to native/native.tests/testData/codegen/exceptions/catch7.kt
index 91ae88c..f17bedf 100644
--- a/kotlin-native/backend.native/tests/runtime/exceptions/catch7.kt
+++ b/native/native.tests/testData/codegen/exceptions/catch7.kt
@@ -2,12 +2,11 @@
* Copyright 2010-2018 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.exceptions.catch7
+// OUTPUT_DATA_FILE: catch7.out
import kotlin.test.*
-@Test fun runTest() {
+fun box(): String {
try {
foo()
} catch (e: Throwable) {
@@ -16,6 +15,7 @@
println(message)
}
}
+ return "OK"
}
fun foo() {
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/catch7.out b/native/native.tests/testData/codegen/exceptions/catch7.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/exceptions/catch7.out
rename to native/native.tests/testData/codegen/exceptions/catch7.out
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/extend0.kt b/native/native.tests/testData/codegen/exceptions/extend0.kt
similarity index 83%
rename from kotlin-native/backend.native/tests/runtime/exceptions/extend0.kt
rename to native/native.tests/testData/codegen/exceptions/extend0.kt
index 298bc0e..08ed39c 100644
--- a/kotlin-native/backend.native/tests/runtime/exceptions/extend0.kt
+++ b/native/native.tests/testData/codegen/exceptions/extend0.kt
@@ -3,16 +3,15 @@
* that can be found in the LICENSE file.
*/
-package runtime.exceptions.extend0
-
import kotlin.test.*
class C : Exception("OK")
-@Test fun runTest() {
+fun box(): String {
try {
throw C()
} catch (e: Throwable) {
println(e.message!!)
}
+ return "OK"
}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt b/native/native.tests/testData/codegen/exceptions/rethrow.kt
similarity index 85%
rename from kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt
rename to native/native.tests/testData/codegen/exceptions/rethrow.kt
index 5de3388..04ff143 100644
--- a/kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt
+++ b/native/native.tests/testData/codegen/exceptions/rethrow.kt
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file.
*/
-package runtime.exceptions.rethtow
-
import kotlin.test.*
-@Test
-fun runTest() {
+fun box(): String {
assertFailsWith<IllegalStateException>("My error") {
try {
error("My error")
@@ -16,4 +13,6 @@
throw e
}
}
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/throw0.kt b/native/native.tests/testData/codegen/exceptions/throw0.kt
similarity index 82%
rename from kotlin-native/backend.native/tests/runtime/basic/throw0.kt
rename to native/native.tests/testData/codegen/exceptions/throw0.kt
index 1970a63..d179f88 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/throw0.kt
+++ b/native/native.tests/testData/codegen/exceptions/throw0.kt
@@ -3,15 +3,13 @@
* that can be found in the LICENSE file.
*/
-package runtime.basic.throw0
-
import kotlin.test.*
-@Test fun runTest() {
+fun box(): String {
val cond = 1
if (cond == 2) throw RuntimeException()
if (cond == 3) throw NoSuchElementException("no such element")
if (cond == 4) throw Error("error happens")
- println("Done")
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt b/native/native.tests/testData/codegen/exceptions/throw_from_catch.kt
similarity index 84%
rename from kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt
rename to native/native.tests/testData/codegen/exceptions/throw_from_catch.kt
index 1522b73..668d61c 100644
--- a/kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt
+++ b/native/native.tests/testData/codegen/exceptions/throw_from_catch.kt
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file.
*/
-package runtime.exceptions.throw_from_catch
-
import kotlin.test.*
-@Test
-fun runTest() {
+fun box(): String {
assertFailsWith<IllegalStateException>("My another error") {
try {
error("My error")
@@ -16,4 +13,5 @@
error("My another error")
}
}
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers0.kt b/native/native.tests/testData/codegen/initializers/initializers0.kt
similarity index 91%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers0.kt
rename to native/native.tests/testData/codegen/initializers/initializers0.kt
index 31d7d291..a911dd0 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers0.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers0.kt
@@ -2,8 +2,7 @@
* Copyright 2010-2018 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.initializers0
+// OUTPUT_DATA_FILE: initializers0.out
import kotlin.test.*
@@ -34,12 +33,14 @@
}
}
-@Test fun runTest() {
+fun box(): String {
println("main")
A.foo()
A.foo()
A.AObj.foo()
A.AObj.foo()
+
+ return "OK"
}
open class B(val a:Int, val b:Int) {
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers0.out b/native/native.tests/testData/codegen/initializers/initializers0.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers0.out
rename to native/native.tests/testData/codegen/initializers/initializers0.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers1.kt b/native/native.tests/testData/codegen/initializers/initializers1.kt
similarity index 82%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers1.kt
rename to native/native.tests/testData/codegen/initializers/initializers1.kt
index 7b8c7cc..63d627b 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers1.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers1.kt
@@ -2,8 +2,7 @@
* Copyright 2010-2018 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.initializers1
+// OUTPUT_DATA_FILE: initializers1.out
import kotlin.test.*
@@ -15,8 +14,10 @@
}
}
-@Test fun runTest() {
+fun box(): String {
val t1 = TestClass()
val t2 = TestClass()
println("Done")
+
+ return "OK"
}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers1.out b/native/native.tests/testData/codegen/initializers/initializers1.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers1.out
rename to native/native.tests/testData/codegen/initializers/initializers1.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers2.kt b/native/native.tests/testData/codegen/initializers/initializers2.kt
similarity index 85%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers2.kt
rename to native/native.tests/testData/codegen/initializers/initializers2.kt
index aa24adc..e24569d 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers2.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers2.kt
@@ -2,6 +2,7 @@
* Copyright 2010-2018 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.
*/
+// OUTPUT_DATA_FILE: initializers2.out
class A(val msg: String) {
init {
@@ -14,9 +15,11 @@
val globalValue2 = A("globalValue2")
val globalValue3 = A("globalValue3")
-fun main(args: Array<String>) {
+fun box(): String {
println(globalValue1.toString())
println(globalValue2.toString())
println(globalValue3.toString())
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers2.out b/native/native.tests/testData/codegen/initializers/initializers2.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers2.out
rename to native/native.tests/testData/codegen/initializers/initializers2.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers3.kt b/native/native.tests/testData/codegen/initializers/initializers3.kt
similarity index 75%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers3.kt
rename to native/native.tests/testData/codegen/initializers/initializers3.kt
index 5dfb0c6..24b4228 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers3.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers3.kt
@@ -2,8 +2,7 @@
* Copyright 2010-2018 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.initializers3
+// OUTPUT_DATA_FILE: initializers3.out
import kotlin.test.*
@@ -11,6 +10,8 @@
var x = Foo(42)
-@Test fun runTest() {
+fun box(): String {
println(x.bar)
+
+ return "OK"
}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers3.out b/native/native.tests/testData/codegen/initializers/initializers3.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers3.out
rename to native/native.tests/testData/codegen/initializers/initializers3.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers4.kt b/native/native.tests/testData/codegen/initializers/initializers4.kt
similarity index 81%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers4.kt
rename to native/native.tests/testData/codegen/initializers/initializers4.kt
index 008b512..0fabb67 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers4.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers4.kt
@@ -2,15 +2,16 @@
* Copyright 2010-2018 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.initializers4
+// OUTPUT_DATA_FILE: initializers4.out
import kotlin.test.*
const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
val DOUBLE = Double.MAX_VALUE - 1.0
-@Test fun runTest() {
+fun box(): String {
println(INT_MAX_POWER_OF_TWO)
println(DOUBLE > 0.0)
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers4.out b/native/native.tests/testData/codegen/initializers/initializers4.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers4.out
rename to native/native.tests/testData/codegen/initializers/initializers4.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers5.kt b/native/native.tests/testData/codegen/initializers/initializers5.kt
similarity index 75%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers5.kt
rename to native/native.tests/testData/codegen/initializers/initializers5.kt
index 0c67dcb..d9cbcc5 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers5.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers5.kt
@@ -2,8 +2,7 @@
* Copyright 2010-2018 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.initializers5
+// OUTPUT_DATA_FILE: initializers5.out
import kotlin.test.*
@@ -12,6 +11,8 @@
val b = A.a
}
-@Test fun runTest() {
+fun box(): String {
println(A.b)
+
+ return "OK"
}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers5.out b/native/native.tests/testData/codegen/initializers/initializers5.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers5.out
rename to native/native.tests/testData/codegen/initializers/initializers5.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers7.kt b/native/native.tests/testData/codegen/initializers/initializers7.kt
similarity index 94%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers7.kt
rename to native/native.tests/testData/codegen/initializers/initializers7.kt
index 7327675..5cded20 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers7.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers7.kt
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
-package runtime.basic.initializers7
-
import kotlin.test.*
object A {
@@ -53,8 +51,10 @@
assertEquals(0, C.c4)
}
-@Test fun runTest() {
+fun box(): String {
assertEquals(A.a1, C.c2)
assertEquals(A.a2, C.c3)
assertEquals(C.c1, C.c4)
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/initializers8.kt b/native/native.tests/testData/codegen/initializers/initializers8.kt
similarity index 80%
rename from kotlin-native/backend.native/tests/runtime/basic/initializers8.kt
rename to native/native.tests/testData/codegen/initializers/initializers8.kt
index d6d77a6..3d06149 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/initializers8.kt
+++ b/native/native.tests/testData/codegen/initializers/initializers8.kt
@@ -3,12 +3,12 @@
* that can be found in the LICENSE file.
*/
-package runtime.basic.initializers8
-
import kotlin.test.*
var globalString = "abc"
-@Test fun runTest() {
+fun box(): String {
assertEquals("abc", globalString)
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/interface0.kt b/native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.kt
similarity index 81%
rename from kotlin-native/backend.native/tests/runtime/basic/interface0.kt
rename to native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.kt
index 347e562..3c246e6 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/interface0.kt
+++ b/native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.kt
@@ -2,8 +2,7 @@
* Copyright 2010-2018 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.interface0
+// OUTPUT_DATA_FILE: interface0.out
import kotlin.test.*
@@ -18,8 +17,10 @@
}
}
-@Test fun runTest() {
+fun box(): String {
val a:A = B()
a.b()
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/interface0.out b/native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/interface0.out
rename to native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.out
diff --git a/native/native.tests/testData/datagen/literals/listof1.kt b/native/native.tests/testData/datagen/literals/listof1.kt
index 3650aa4..a29b3c5 100644
--- a/native/native.tests/testData/datagen/literals/listof1.kt
+++ b/native/native.tests/testData/datagen/literals/listof1.kt
@@ -2,15 +2,19 @@
* Copyright 2010-2018 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.
*/
-// OUTPUT_DATA_FILE: listof1.out
-// IGNORE_BACKEND: NATIVE
+// WITH_STDLIB
+// This test verifies absence of buggy optimzation removed in https://github.com/JetBrains/kotlin/commit/d222e9587
import kotlin.test.*
fun box(): String {
val list = foo()
- println(list === foo())
- println(list.toString())
+ if (!(list == foo()))
+ return "FAIL =="
+ if (list === foo())
+ return "FAIL ===: two listOf() having same contents are not optimized to be referentially equal in all backends, but are now unexpectedly referentially equal"
+ if (list.toString() != "[a, b, c]")
+ return "FAIL toString(): ${list.toString()}"
return "OK"
}
diff --git a/native/native.tests/testData/datagen/literals/listof1.out b/native/native.tests/testData/datagen/literals/listof1.out
deleted file mode 100644
index c15eb0c..0000000
--- a/native/native.tests/testData/datagen/literals/listof1.out
+++ /dev/null
@@ -1,2 +0,0 @@
-true
-[a, b, c]
diff --git a/native/native.tests/testData/datagen/literals/strdedup1.kt b/native/native.tests/testData/datagen/literals/strdedup1.kt
index 223a12d..977acd4 100644
--- a/native/native.tests/testData/datagen/literals/strdedup1.kt
+++ b/native/native.tests/testData/datagen/literals/strdedup1.kt
@@ -1,4 +1,3 @@
-// OUTPUT_DATA_FILE: strdedup1.out
/*
* Copyright 2010-2018 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.
@@ -9,8 +8,10 @@
fun box(): String {
val str1 = "Hello"
val str2 = "Hello"
- println(str1 == str2)
- println(str1 === str2)
+ if (!(str1 == str2))
+ return "FAIL =="
+ if (!(str1 === str2))
+ return "FAIL ==="
return "OK"
}
diff --git a/native/native.tests/testData/datagen/literals/strdedup1.out b/native/native.tests/testData/datagen/literals/strdedup1.out
deleted file mode 100644
index bb101b6..0000000
--- a/native/native.tests/testData/datagen/literals/strdedup1.out
+++ /dev/null
@@ -1,2 +0,0 @@
-true
-true
diff --git a/native/native.tests/testData/datagen/literals/strdedup2.kt b/native/native.tests/testData/datagen/literals/strdedup2.kt
index 0efa7e5..01ad80b 100644
--- a/native/native.tests/testData/datagen/literals/strdedup2.kt
+++ b/native/native.tests/testData/datagen/literals/strdedup2.kt
@@ -2,18 +2,20 @@
* Copyright 2010-2018 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.
*/
-// OUTPUT_DATA_FILE: strdedup2.out
// TODO: string deduplication across several components seems to require
// linking them as bitcode modules before translating to machine code.
-// IGNORE_BACKEND: NATIVE
+// IGNORE_BACKEND: NATIVE, JVM, JVM_IR
+// WITH_STDLIB
import kotlin.test.*
fun box(): String {
val str1 = ""
val str2 = "hello".subSequence(2, 2)
- println(str1 == str2)
- println(str1 === str2)
+ if(!(str1 == str2))
+ return "FAIL =="
+ if(!(str1 === str2))
+ return "FAIL ==="
return "OK"
}
diff --git a/native/native.tests/testData/datagen/literals/strdedup2.out b/native/native.tests/testData/datagen/literals/strdedup2.out
deleted file mode 100644
index bb101b6..0000000
--- a/native/native.tests/testData/datagen/literals/strdedup2.out
+++ /dev/null
@@ -1,2 +0,0 @@
-true
-true
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_basic.kt b/native/native.tests/testData/runtime/basic/cleaner_basic.kt
similarity index 91%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_basic.kt
rename to native/native.tests/testData/runtime/basic/cleaner_basic.kt
index 59b3298..de1445b 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_basic.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_basic.kt
@@ -2,6 +2,11 @@
* 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.
*/
+// Ideally, this test must fail with gcType=NOOP with any cache mode.
+// KT-63944: unfortunately, GC flavours are silently not switched in presence of caches.
+// As soon the issue would be fixed, please remove `&& cacheMode=NO` from next line.
+// IGNORE_NATIVE: gcType=NOOP && cacheMode=NO
+
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, FreezingIsDeprecated::class,
kotlin.native.runtime.NativeRuntimeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class)
@@ -36,7 +41,6 @@
}
}
-@Test
fun testCleanerLambda() {
val called = AtomicBoolean(false);
var funBoxWeak: WeakReference<FunBox>? = null
@@ -60,7 +64,6 @@
assertNull(funBoxWeak!!.value)
}
-@Test
fun testCleanerNonSharedLambda() {
// Only for experimental MM.
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
@@ -88,7 +91,6 @@
assertNull(funBoxWeak!!.value)
}
-@Test
fun testCleanerAnonymousFunction() {
val called = AtomicBoolean(false);
var funBoxWeak: WeakReference<FunBox>? = null
@@ -112,7 +114,6 @@
assertNull(funBoxWeak!!.value)
}
-@Test
fun testCleanerNonSharedAnonymousFunction() {
// Only for experimental MM.
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
@@ -140,7 +141,6 @@
assertNull(funBoxWeak!!.value)
}
-@Test
fun testCleanerFunctionReference() {
val called = AtomicBoolean(false);
var funBoxWeak: WeakReference<FunBox>? = null
@@ -164,7 +164,6 @@
assertNull(funBoxWeak!!.value)
}
-@Test
fun testCleanerNonSharedFunctionReference() {
// Only for experimental MM.
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) {
@@ -192,7 +191,6 @@
assertNull(funBoxWeak!!.value)
}
-@Test
fun testCleanerFailWithNonShareableArgument() {
// Only for legacy MM.
if (Platform.memoryModel == MemoryModel.EXPERIMENTAL) {
@@ -204,7 +202,6 @@
}
}
-@Test
fun testCleanerCleansWithoutGC() {
val called = AtomicBoolean(false);
var funBoxWeak: WeakReference<FunBox>? = null
@@ -238,7 +235,6 @@
val globalInt = AtomicInt(0)
-@Test
fun testCleanerWithInt() {
var cleanerWeak: WeakReference<Cleaner>? = null
{
@@ -258,7 +254,6 @@
val globalPtr = AtomicNativePtr(NativePtr.NULL)
-@Test
fun testCleanerWithNativePtr() {
var cleanerWeak: WeakReference<Cleaner>? = null
{
@@ -276,7 +271,6 @@
assertEquals(NativePtr.NULL + 42L, globalPtr.value)
}
-@Test
fun testCleanerWithException() {
val called = AtomicBoolean(false);
var funBoxWeak: WeakReference<FunBox>? = null
@@ -300,3 +294,19 @@
// Even though the block failed, the captured funBox is freed.
assertNull(funBoxWeak!!.value)
}
+
+fun box(): String {
+ testCleanerAnonymousFunction()
+ testCleanerLambda()
+ testCleanerCleansWithoutGC()
+ testCleanerFunctionReference()
+ testCleanerFailWithNonShareableArgument()
+ testCleanerNonSharedAnonymousFunction()
+ testCleanerNonSharedFunctionReference()
+ testCleanerNonSharedLambda()
+ testCleanerWithException()
+ testCleanerWithInt()
+ testCleanerWithNativePtr()
+
+ return "OK"
+}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_with_checker.kt b/native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.kt
similarity index 67%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_with_checker.kt
rename to native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.kt
index 397d2db..a3138cc 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_with_checker.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.kt
@@ -2,13 +2,20 @@
* 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.
*/
+// OUTPUT_DATA_FILE: cleaner_in_main_with_checker.out
+
+// Ideally, this test must fail with gcType=NOOP with any cache mode.
+// KT-63944: unfortunately, GC flavours are silently not switched in presence of caches.
+// As soon the issue would be fixed, please remove `&& cacheMode=NO` from next line.
+// IGNORE_NATIVE: gcType=NOOP && cacheMode=NO
+
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
import kotlin.native.ref.Cleaner
import kotlin.native.ref.createCleaner
import kotlin.native.Platform
-fun main() {
+fun box(): String {
// Cleaner holds onto a finalization lambda. If it doesn't get executed,
// the memory will leak. Suppress memory leak checker to check for cleaners
// leak only.
@@ -19,4 +26,6 @@
createCleaner(42) {
println(it)
}
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_with_checker.out b/native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_with_checker.out
rename to native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_without_checker.kt b/native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.kt
similarity index 88%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_without_checker.kt
rename to native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.kt
index 6bd1005..3ef50a7 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_without_checker.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.kt
@@ -1,3 +1,4 @@
+// OUTPUT_DATA_FILE: cleaner_in_main_without_checker.out
/*
* 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.
@@ -7,7 +8,7 @@
import kotlin.native.ref.createCleaner
import kotlin.native.Platform
-fun main() {
+fun box(): String {
// Cleaner holds onto a finalization lambda. If it doesn't get executed,
// the memory will leak. Suppress memory leak checker to check for cleaners
// leak only.
@@ -18,4 +19,6 @@
createCleaner(42) {
println(it)
}
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_without_checker.out b/native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_in_main_without_checker.out
rename to native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_tls_main_without_checker.kt b/native/native.tests/testData/runtime/basic/cleaner_in_tls_main_without_checker.kt
similarity index 95%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_in_tls_main_without_checker.kt
rename to native/native.tests/testData/runtime/basic/cleaner_in_tls_main_without_checker.kt
index 1a3fe81..497d401 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_tls_main_without_checker.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_in_tls_main_without_checker.kt
@@ -14,7 +14,7 @@
@ThreadLocal
var tlsCleaner: Cleaner? = null
-fun main() {
+fun box(): String {
// Cleaner holds onto a finalization lambda. If it doesn't get executed,
// the memory will leak. Suppress memory leak checker to check for cleaners
// leak only.
@@ -24,4 +24,6 @@
tlsCleaner = createCleaner(42) {
println(it)
}
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_tls_worker.kt b/native/native.tests/testData/runtime/basic/cleaner_in_tls_worker.kt
similarity index 73%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_in_tls_worker.kt
rename to native/native.tests/testData/runtime/basic/cleaner_in_tls_worker.kt
index e8ba79a..ff99793 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_in_tls_worker.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_in_tls_worker.kt
@@ -2,6 +2,11 @@
* 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.
*/
+// Ideally, this test must fail with gcType=NOOP with any cache mode.
+// KT-63944: unfortunately, GC flavours are silently not switched in presence of caches.
+// As soon the issue would be fixed, please remove `&& cacheMode=NO` from next line.
+// IGNORE_NATIVE: gcType=NOOP && cacheMode=NO
+
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class, ObsoleteWorkersApi::class)
import kotlin.test.*
@@ -18,7 +23,7 @@
val value = AtomicInt(0)
-fun main() {
+fun box(): String {
val worker = Worker.start()
worker.execute(TransferMode.SAFE, {}) {
@@ -33,4 +38,6 @@
waitCleanerWorker()
assertEquals(42, value.value)
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt b/native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.kt
similarity index 85%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt
rename to native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.kt
index b034df0..16f19af 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.kt
@@ -1,3 +1,4 @@
+// OUTPUT_DATA_FILE: cleaner_leak_without_checker.out
/*
* 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.
@@ -15,7 +16,9 @@
println(it)
}
-fun main() {
+fun box(): String {
// Make sure cleaner is initialized.
assertNotNull(globalCleaner)
+
+ return "OK"
}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.out b/native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.out
similarity index 100%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.out
rename to native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.out
diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_workers.kt b/native/native.tests/testData/runtime/basic/cleaner_workers.kt
similarity index 90%
rename from kotlin-native/backend.native/tests/runtime/basic/cleaner_workers.kt
rename to native/native.tests/testData/runtime/basic/cleaner_workers.kt
index d8591d7..41db6b1 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_workers.kt
+++ b/native/native.tests/testData/runtime/basic/cleaner_workers.kt
@@ -2,6 +2,11 @@
* 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.
*/
+// Ideally, this test must fail with gcType=NOOP with any cache mode.
+// KT-63944: unfortunately, GC flavours are silently not switched in presence of caches.
+// As soon the issue would be fixed, please remove `&& cacheMode=NO` from next line.
+// IGNORE_NATIVE: gcType=NOOP && cacheMode=NO
+
@file:OptIn(ExperimentalStdlibApi::class, FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class, ObsoleteWorkersApi::class)
package runtime.basic.cleaner_workers
@@ -177,3 +182,13 @@
worker.requestTermination().result
}
+
+fun box(): String {
+ testCleanerDestroyWithChild()
+ testCleanerWithTLS()
+ testCleanerDestroyShared()
+ testCleanerDestroyInMain()
+ testCleanerDestroyInChild()
+
+ return "OK"
+}
diff --git a/kotlin-native/backend.native/tests/runtime/basic/collectReferenceFieldValues.kt b/native/native.tests/testData/runtime/basic/collectReferenceFieldValues.kt
similarity index 87%
rename from kotlin-native/backend.native/tests/runtime/basic/collectReferenceFieldValues.kt
rename to native/native.tests/testData/runtime/basic/collectReferenceFieldValues.kt
index b38ee9e..66d3fd1 100644
--- a/kotlin-native/backend.native/tests/runtime/basic/collectReferenceFieldValues.kt
+++ b/native/native.tests/testData/runtime/basic/collectReferenceFieldValues.kt
@@ -2,6 +2,10 @@
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
+// Ideally, this test must fail with gcType=NOOP with any cache mode.
+// KT-63944: unfortunately, GC flavours are silently not switched in presence of caches.
+// As soon the issue would be fixed, please remove `&& cacheMode=NO` from next line.
+// IGNORE_NATIVE: gcType=NOOP && cacheMode=NO
import kotlin.native.internal.*
import kotlin.test.*
@@ -35,7 +39,6 @@
lateinit var r: IntArray
}
-@Test
fun `big class with mixed values`() {
val lst = listOf(1, 2, 3)
val ia = intArrayOf(1, 2, 3)
@@ -70,42 +73,48 @@
assertContains(fields, BoxInt(5))
assertContains(fields, BoxA(a6))}
-@Test
fun `call on primitive`() {
assertEquals(1.collectReferenceFieldValues(), emptyList<Any>())
assertEquals(123456.collectReferenceFieldValues(), emptyList<Any>())
}
-@Test
fun `call on value over primitive class`() {
assertEquals(BoxInt(1).collectReferenceFieldValues(), emptyList<Any>())
assertEquals(BoxBoxInt(BoxInt(1)).collectReferenceFieldValues(), emptyList<Any>())
}
-@Test
fun `call on value class`() {
val a1 = A(1)
assertEquals(BoxA(a1).collectReferenceFieldValues(), listOf(a1))
assertEquals(BoxBoxA(BoxA(a1)).collectReferenceFieldValues(), listOf(a1))
}
-@Test
fun `call on String`() {
assertEquals("1234".collectReferenceFieldValues(), emptyList<Any>())
assertEquals("".collectReferenceFieldValues(), emptyList<Any>())
}
-@Test
fun `call on primitive array`() {
assertEquals(intArrayOf(1, 2, 3).collectReferenceFieldValues(), emptyList<Any>())
assertEquals(intArrayOf().collectReferenceFieldValues(), emptyList<Any>())
}
-@Test
fun `call on array`() {
assertEquals(arrayOf(1, 2, 3).collectReferenceFieldValues(), listOf<Any>(1, 2, 3))
assertEquals(arrayOf(null, "10", null, 3).collectReferenceFieldValues(), listOf<Any>("10", 3))
assertEquals(arrayOf<Any>().collectReferenceFieldValues(), emptyList<Any>())
assertEquals(emptyArray<Any>().collectReferenceFieldValues(), emptyList<Any>())
assertEquals(emptyArray<Any?>().collectReferenceFieldValues(), emptyList<Any>())
-}
\ No newline at end of file
+}
+
+fun box(): String {
+ `big class with mixed values`()
+ `call on value over primitive class`()
+ `call on primitive`()
+ `call on array`()
+ `call on String`()
+ `call on value class`()
+ `call on primitive array`()
+
+ return "OK"
+}
diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java
index 12deb4a..18dacf7 100644
--- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java
+++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java
@@ -205,6 +205,12 @@
}
@Test
+ @TestMetadata("statements0.kt")
+ public void testStatements0() throws Exception {
+ runTest("native/native.tests/testData/codegen/basics/statements0.kt");
+ }
+
+ @Test
@TestMetadata("superFunCall.kt")
public void testSuperFunCall() throws Exception {
runTest("native/native.tests/testData/codegen/basics/superFunCall.kt");
@@ -1238,6 +1244,12 @@
}
@Test
+ @TestMetadata("enum_equals.kt")
+ public void testEnum_equals() throws Exception {
+ runTest("native/native.tests/testData/codegen/enum/enum_equals.kt");
+ }
+
+ @Test
@TestMetadata("interfaceCallNoEntryClass.kt")
public void testInterfaceCallNoEntryClass() throws Exception {
runTest("native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.kt");
@@ -1474,6 +1486,61 @@
}
@Nested
+ @TestMetadata("native/native.tests/testData/codegen/exceptions")
+ @TestDataPath("$PROJECT_ROOT")
+ @Tag("frontend-fir")
+ @FirPipeline()
+ @UseExtTestCaseGroupProvider()
+ public class Exceptions {
+ @Test
+ public void testAllFilesPresentInExceptions() throws Exception {
+ KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/codegen/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
+ }
+
+ @Test
+ @TestMetadata("catch1.kt")
+ public void testCatch1() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/catch1.kt");
+ }
+
+ @Test
+ @TestMetadata("catch2.kt")
+ public void testCatch2() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/catch2.kt");
+ }
+
+ @Test
+ @TestMetadata("catch7.kt")
+ public void testCatch7() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/catch7.kt");
+ }
+
+ @Test
+ @TestMetadata("extend0.kt")
+ public void testExtend0() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/extend0.kt");
+ }
+
+ @Test
+ @TestMetadata("rethrow.kt")
+ public void testRethrow() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/rethrow.kt");
+ }
+
+ @Test
+ @TestMetadata("throw0.kt")
+ public void testThrow0() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/throw0.kt");
+ }
+
+ @Test
+ @TestMetadata("throw_from_catch.kt")
+ public void testThrow_from_catch() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/throw_from_catch.kt");
+ }
+ }
+
+ @Nested
@TestMetadata("native/native.tests/testData/codegen/funInterface")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@@ -1812,6 +1879,54 @@
}
@Test
+ @TestMetadata("initializers0.kt")
+ public void testInitializers0() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers0.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers1.kt")
+ public void testInitializers1() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers1.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers2.kt")
+ public void testInitializers2() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers2.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers3.kt")
+ public void testInitializers3() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers3.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers4.kt")
+ public void testInitializers4() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers4.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers5.kt")
+ public void testInitializers5() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers5.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers7.kt")
+ public void testInitializers7() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers7.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers8.kt")
+ public void testInitializers8() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers8.kt");
+ }
+
+ @Test
@TestMetadata("object.kt")
public void testObject() throws Exception {
runTest("native/native.tests/testData/codegen/initializers/object.kt");
@@ -2312,6 +2427,12 @@
public void testFunctionNameClash() throws Exception {
runTest("native/native.tests/testData/codegen/interfaceCallsNCasts/functionNameClash.kt");
}
+
+ @Test
+ @TestMetadata("interface0.kt")
+ public void testInterface0() throws Exception {
+ runTest("native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.kt");
+ }
}
@Nested
@@ -3150,6 +3271,80 @@
}
@Nested
+ @TestMetadata("native/native.tests/testData/runtime")
+ @TestDataPath("$PROJECT_ROOT")
+ @Tag("frontend-fir")
+ @FirPipeline()
+ @UseExtTestCaseGroupProvider()
+ public class Runtime {
+ @Test
+ public void testAllFilesPresentInRuntime() throws Exception {
+ KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/runtime"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
+ }
+
+ @Nested
+ @TestMetadata("native/native.tests/testData/runtime/basic")
+ @TestDataPath("$PROJECT_ROOT")
+ @Tag("frontend-fir")
+ @FirPipeline()
+ @UseExtTestCaseGroupProvider()
+ public class Basic {
+ @Test
+ public void testAllFilesPresentInBasic() throws Exception {
+ KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/runtime/basic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
+ }
+
+ @Test
+ @TestMetadata("cleaner_basic.kt")
+ public void testCleaner_basic() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_basic.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_main_with_checker.kt")
+ public void testCleaner_in_main_with_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_main_without_checker.kt")
+ public void testCleaner_in_main_without_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_tls_main_without_checker.kt")
+ public void testCleaner_in_tls_main_without_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_tls_main_without_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_tls_worker.kt")
+ public void testCleaner_in_tls_worker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_tls_worker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_leak_without_checker.kt")
+ public void testCleaner_leak_without_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_workers.kt")
+ public void testCleaner_workers() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_workers.kt");
+ }
+
+ @Test
+ @TestMetadata("collectReferenceFieldValues.kt")
+ public void testCollectReferenceFieldValues() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/collectReferenceFieldValues.kt");
+ }
+ }
+ }
+
+ @Nested
@TestMetadata("native/native.tests/testData/serialization")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java
index 7e01c8c..a85b5c9 100644
--- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java
+++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java
@@ -193,6 +193,12 @@
}
@Test
+ @TestMetadata("statements0.kt")
+ public void testStatements0() throws Exception {
+ runTest("native/native.tests/testData/codegen/basics/statements0.kt");
+ }
+
+ @Test
@TestMetadata("superFunCall.kt")
public void testSuperFunCall() throws Exception {
runTest("native/native.tests/testData/codegen/basics/superFunCall.kt");
@@ -1200,6 +1206,12 @@
}
@Test
+ @TestMetadata("enum_equals.kt")
+ public void testEnum_equals() throws Exception {
+ runTest("native/native.tests/testData/codegen/enum/enum_equals.kt");
+ }
+
+ @Test
@TestMetadata("interfaceCallNoEntryClass.kt")
public void testInterfaceCallNoEntryClass() throws Exception {
runTest("native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.kt");
@@ -1434,6 +1446,59 @@
}
@Nested
+ @TestMetadata("native/native.tests/testData/codegen/exceptions")
+ @TestDataPath("$PROJECT_ROOT")
+ @UseExtTestCaseGroupProvider()
+ public class Exceptions {
+ @Test
+ public void testAllFilesPresentInExceptions() throws Exception {
+ KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/codegen/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
+ }
+
+ @Test
+ @TestMetadata("catch1.kt")
+ public void testCatch1() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/catch1.kt");
+ }
+
+ @Test
+ @TestMetadata("catch2.kt")
+ public void testCatch2() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/catch2.kt");
+ }
+
+ @Test
+ @TestMetadata("catch7.kt")
+ public void testCatch7() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/catch7.kt");
+ }
+
+ @Test
+ @TestMetadata("extend0.kt")
+ public void testExtend0() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/extend0.kt");
+ }
+
+ @Test
+ @TestMetadata("rethrow.kt")
+ public void testRethrow() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/rethrow.kt");
+ }
+
+ @Test
+ @TestMetadata("throw0.kt")
+ public void testThrow0() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/throw0.kt");
+ }
+
+ @Test
+ @TestMetadata("throw_from_catch.kt")
+ public void testThrow_from_catch() throws Exception {
+ runTest("native/native.tests/testData/codegen/exceptions/throw_from_catch.kt");
+ }
+ }
+
+ @Nested
@TestMetadata("native/native.tests/testData/codegen/funInterface")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
@@ -1766,6 +1831,54 @@
}
@Test
+ @TestMetadata("initializers0.kt")
+ public void testInitializers0() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers0.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers1.kt")
+ public void testInitializers1() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers1.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers2.kt")
+ public void testInitializers2() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers2.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers3.kt")
+ public void testInitializers3() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers3.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers4.kt")
+ public void testInitializers4() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers4.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers5.kt")
+ public void testInitializers5() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers5.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers7.kt")
+ public void testInitializers7() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers7.kt");
+ }
+
+ @Test
+ @TestMetadata("initializers8.kt")
+ public void testInitializers8() throws Exception {
+ runTest("native/native.tests/testData/codegen/initializers/initializers8.kt");
+ }
+
+ @Test
@TestMetadata("object.kt")
public void testObject() throws Exception {
runTest("native/native.tests/testData/codegen/initializers/object.kt");
@@ -2258,6 +2371,12 @@
public void testFunctionNameClash() throws Exception {
runTest("native/native.tests/testData/codegen/interfaceCallsNCasts/functionNameClash.kt");
}
+
+ @Test
+ @TestMetadata("interface0.kt")
+ public void testInterface0() throws Exception {
+ runTest("native/native.tests/testData/codegen/interfaceCallsNCasts/interface0.kt");
+ }
}
@Nested
@@ -3060,6 +3179,76 @@
}
@Nested
+ @TestMetadata("native/native.tests/testData/runtime")
+ @TestDataPath("$PROJECT_ROOT")
+ @UseExtTestCaseGroupProvider()
+ public class Runtime {
+ @Test
+ public void testAllFilesPresentInRuntime() throws Exception {
+ KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/runtime"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
+ }
+
+ @Nested
+ @TestMetadata("native/native.tests/testData/runtime/basic")
+ @TestDataPath("$PROJECT_ROOT")
+ @UseExtTestCaseGroupProvider()
+ public class Basic {
+ @Test
+ public void testAllFilesPresentInBasic() throws Exception {
+ KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/runtime/basic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
+ }
+
+ @Test
+ @TestMetadata("cleaner_basic.kt")
+ public void testCleaner_basic() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_basic.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_main_with_checker.kt")
+ public void testCleaner_in_main_with_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_main_with_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_main_without_checker.kt")
+ public void testCleaner_in_main_without_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_main_without_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_tls_main_without_checker.kt")
+ public void testCleaner_in_tls_main_without_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_tls_main_without_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_in_tls_worker.kt")
+ public void testCleaner_in_tls_worker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_in_tls_worker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_leak_without_checker.kt")
+ public void testCleaner_leak_without_checker() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_leak_without_checker.kt");
+ }
+
+ @Test
+ @TestMetadata("cleaner_workers.kt")
+ public void testCleaner_workers() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/cleaner_workers.kt");
+ }
+
+ @Test
+ @TestMetadata("collectReferenceFieldValues.kt")
+ public void testCollectReferenceFieldValues() throws Exception {
+ runTest("native/native.tests/testData/runtime/basic/collectReferenceFieldValues.kt");
+ }
+ }
+ }
+
+ @Nested
@TestMetadata("native/native.tests/testData/serialization")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
diff --git a/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt b/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt
index 5619d67..b723e01 100644
--- a/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt
+++ b/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt
@@ -39,6 +39,7 @@
model("codegen", targetBackend = TargetBackend.NATIVE)
model("datagen", targetBackend = TargetBackend.NATIVE)
model("lower", targetBackend = TargetBackend.NATIVE)
+ model("runtime", targetBackend = TargetBackend.NATIVE)
model("serialization", targetBackend = TargetBackend.NATIVE)
}
testClass<AbstractNativeCodegenBoxTest>(
@@ -51,6 +52,7 @@
model("codegen", targetBackend = TargetBackend.NATIVE)
model("datagen", targetBackend = TargetBackend.NATIVE)
model("lower", targetBackend = TargetBackend.NATIVE)
+ model("runtime", targetBackend = TargetBackend.NATIVE)
model("serialization", targetBackend = TargetBackend.NATIVE)
}
}
diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt
index d8126ba..7045968 100644
--- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt
+++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt
@@ -927,6 +927,7 @@
private val CACHE_MODE_NAMES = CacheMode.Alias.entries.map { it.name }
private val TEST_MODE_NAMES = TestMode.entries.map { it.name }
private val OPTIMIZATION_MODE_NAMES = OptimizationMode.entries.map { it.name }
+private val GC_TYPE_NAMES = GCType.entries.map { it.name }
private fun Settings.isIgnoredWithNativeDirective(
directives: Directives,
@@ -967,6 +968,7 @@
ClassLevelProperty.TEST_MODE.shortName -> get<TestMode>().name to TEST_MODE_NAMES
ClassLevelProperty.OPTIMIZATION_MODE.shortName -> get<OptimizationMode>().name to OPTIMIZATION_MODE_NAMES
ClassLevelProperty.TEST_TARGET.shortName -> get<KotlinNativeTargets>().testTarget.name to null
+ ClassLevelProperty.GC_TYPE.shortName -> get<GCType>().name to GC_TYPE_NAMES
else -> throw AssertionError("ClassLevelProperty name: $propName is not yet supported in $directiveGeneral* test directives.")
}
val valueFromTestDirective = matchResult.groups[2]?.value!!