diff --git a/compiler/testData/codegen/box/argumentOrder/varargAndDefaultParameters_ForNative.kt b/compiler/testData/codegen/box/argumentOrder/varargAndDefaultParameters_ForNative.kt new file mode 100644 index 00000000000..969dc8e84f8 --- /dev/null +++ b/compiler/testData/codegen/box/argumentOrder/varargAndDefaultParameters_ForNative.kt @@ -0,0 +1,54 @@ +// NO_CHECK_LAMBDA_INLINING +// FILE: 1.kt +// WITH_RUNTIME +// TARGET_BACKEND: NATIVE +package test + +open class A(val value: String) + +var invokeOrder = "" + +inline fun inlineFun( + vararg constraints: A, + receiver: String = { invokeOrder += " default receiver"; "DEFAULT" }(), + init: String +): String { + return constraints.map { it.value }.joinToString() + ", " + receiver + ", " + init +} + +// FILE: 2.kt +import test.* + + +var result = "" +fun box(): String { + + result = "" + invokeOrder = "" + result = inlineFun(constraints = { invokeOrder += "constraints";A("C") }(), + receiver = { invokeOrder += " receiver"; "R" }(), + init = { invokeOrder += " init"; "I" }()) + if (result != "C, R, I") return "fail 1: $result" + + if (invokeOrder != "constraints receiver init") return "fail 2: $invokeOrder" + + result = "" + invokeOrder = "" + result = inlineFun(init = { invokeOrder += "init"; "I" }(), + constraints = { invokeOrder += "constraints";A("C") }(), + receiver = { invokeOrder += " receiver"; "R" }() + ) + if (result != "C, R, I") return "fail 3: $result" + //Change test after KT-17691 FIX + if (invokeOrder != "init receiverconstraints") return "fail 4: $invokeOrder" + + result = "" + invokeOrder = "" + result = inlineFun(init = { invokeOrder += "init"; "I" }(), + constraints = { invokeOrder += " constraints";A("C") }()) + if (result != "C, DEFAULT, I") return "fail 5: $result" + if (invokeOrder != "init constraints default receiver") return "fail 6: $invokeOrder" + + return "OK" +} + diff --git a/compiler/testData/codegen/box/arrays/arraysAreCloneable.kt b/compiler/testData/codegen/box/arrays/arraysAreCloneable.kt index 52075d459d7..f0860dadc0a 100644 --- a/compiler/testData/codegen/box/arrays/arraysAreCloneable.kt +++ b/compiler/testData/codegen/box/arrays/arraysAreCloneable.kt @@ -1,5 +1,5 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS, NATIVE fun foo(x: Cloneable) = x diff --git a/compiler/testData/codegen/box/arrays/cloneArray.kt b/compiler/testData/codegen/box/arrays/cloneArray.kt index 8e29271c7d7..fe7ae5ff309 100644 --- a/compiler/testData/codegen/box/arrays/cloneArray.kt +++ b/compiler/testData/codegen/box/arrays/cloneArray.kt @@ -1,5 +1,5 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS, NATIVE // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/arrays/clonePrimitiveArrays.kt b/compiler/testData/codegen/box/arrays/clonePrimitiveArrays.kt index dc6646587d6..578c79c0d3c 100644 --- a/compiler/testData/codegen/box/arrays/clonePrimitiveArrays.kt +++ b/compiler/testData/codegen/box/arrays/clonePrimitiveArrays.kt @@ -1,5 +1,5 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS, NATIVE // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/arrays/kt4348.kt b/compiler/testData/codegen/box/arrays/kt4348.kt index 4ea639148ca..aba4a1922d9 100644 --- a/compiler/testData/codegen/box/arrays/kt4348.kt +++ b/compiler/testData/codegen/box/arrays/kt4348.kt @@ -5,9 +5,6 @@ operator fun String.get(vararg value: Any) : String { operator fun Int.get(vararg value: Any) : Int { return if (value[0] == 44 && value[1] == "example") 1 else 0 } -fun main(args: Array) { - 12 [44, "example"] -} fun box(): String { if ("foo" [44, "example"] != "OK") return "fail1" diff --git a/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt b/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt index de43ac414e1..f87032e9a3b 100644 --- a/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt +++ b/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt @@ -46,6 +46,14 @@ fun testFloatArray() { throw AssertionError() } +fun testDoubleArray() { + DoubleArray(5) { i -> + if (i == 3) return + i.toDouble() + } + throw AssertionError() +} + fun box(): String { testArray() testIntArray() @@ -53,5 +61,6 @@ fun box(): String { testBooleanArray() testCharArray() testFloatArray() + testDoubleArray() return "OK" } diff --git a/compiler/testData/codegen/box/bridges/kt1959.kt b/compiler/testData/codegen/box/bridges/kt1959.kt index e7bfcbaa2c8..e820d707615 100644 --- a/compiler/testData/codegen/box/bridges/kt1959.kt +++ b/compiler/testData/codegen/box/bridges/kt1959.kt @@ -6,8 +6,7 @@ class B(): A() { override fun f(args : Array) {} } -fun main(args: Array) { +fun box(): String { B() -} - -fun box(): String = "OK" + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt b/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt index f3aa01b2ffb..15824f1f47e 100644 --- a/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt +++ b/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt @@ -1,5 +1,5 @@ // TODO: investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS // See https://youtrack.jetbrains.com/issue/KT-14938 // WITH_REFLECT diff --git a/compiler/testData/codegen/box/controlStructures/kt2259.kt b/compiler/testData/codegen/box/controlStructures/kt2259.kt index 7b695efee06..f0d79145682 100644 --- a/compiler/testData/codegen/box/controlStructures/kt2259.kt +++ b/compiler/testData/codegen/box/controlStructures/kt2259.kt @@ -1,4 +1,4 @@ -fun main(args: Array) { +fun foo(args: Array) { try { } finally { try { diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec.kt index 7123da47133..fcc0cf8bf29 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec.kt @@ -1,6 +1,5 @@ // WITH_RUNTIME // WITH_COROUTINES -// IGNORE_BACKEND: NATIVE import helpers.* import kotlin.coroutines.experimental.* import kotlin.coroutines.experimental.intrinsics.* diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt index 6fcb2a1f7a2..680af4e20cf 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt @@ -1,6 +1,5 @@ // WITH_RUNTIME // WITH_COROUTINES -// IGNORE_BACKEND: NATIVE import helpers.* import kotlin.coroutines.experimental.* import kotlin.coroutines.experimental.intrinsics.* diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt index 845db0b8be0..20416637b3d 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: NATIVE // WITH_RUNTIME // WITH_COROUTINES import helpers.* diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt index 85f0f44f878..353f5f3f5a4 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: NATIVE // WITH_RUNTIME // WITH_COROUTINES // CHECK_BYTECODE_LISTING diff --git a/compiler/testData/codegen/box/localClasses/kt2873.kt b/compiler/testData/codegen/box/localClasses/kt2873.kt index 6bb8dafadfd..be5008511ac 100644 --- a/compiler/testData/codegen/box/localClasses/kt2873.kt +++ b/compiler/testData/codegen/box/localClasses/kt2873.kt @@ -6,10 +6,6 @@ fun foo() : String { return u() } -fun main(args: Array) { - foo() -} - fun box(): String { - return foo() + return foo() } \ No newline at end of file diff --git a/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt b/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt index 7eeb15cf184..4b45ed81a12 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/kt14597_full.kt @@ -1,9 +1,5 @@ enum class En { A, B, ะก } -fun main(args: Array) { - -} - fun box(): String { var res1 = "fail" var res2 = "fail2" diff --git a/compiler/testData/codegen/box/when/stringOptimization/sameHashCode.kt b/compiler/testData/codegen/box/when/stringOptimization/sameHashCode.kt index 2114ac50d26..fd4d11e6b65 100644 --- a/compiler/testData/codegen/box/when/stringOptimization/sameHashCode.kt +++ b/compiler/testData/codegen/box/when/stringOptimization/sameHashCode.kt @@ -1,5 +1,5 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS, NATIVE // WITH_RUNTIME diff --git a/compiler/testData/codegen/boxInline/argumentOrder/varargAndDefaultParameters.kt b/compiler/testData/codegen/boxInline/argumentOrder/varargAndDefaultParameters.kt index 6bff7d61719..af27b516ce2 100644 --- a/compiler/testData/codegen/boxInline/argumentOrder/varargAndDefaultParameters.kt +++ b/compiler/testData/codegen/boxInline/argumentOrder/varargAndDefaultParameters.kt @@ -1,6 +1,7 @@ // NO_CHECK_LAMBDA_INLINING // FILE: 1.kt // WITH_RUNTIME +// IGNORE_BACKEND: NATIVE package test open class A(val value: String) @@ -29,7 +30,7 @@ fun box(): String { init = { invokeOrder += " init"; "I" }()) if (result != "C, R, I") return "fail 1: $result" - //Change test after KT-17691 FIX + //Change test after KT-17691 FIX; and remove cloned test for Native (enable this). if (invokeOrder != " receiver initconstraints") return "fail 2: $invokeOrder" result = "" diff --git a/compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/jvmStaticDefault.kt b/compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/jvmStaticDefault.kt index d6f75c32cd7..94f9a3e282d 100644 --- a/compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/jvmStaticDefault.kt +++ b/compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/jvmStaticDefault.kt @@ -1,7 +1,7 @@ // FILE: 1.kt // LANGUAGE_VERSION: 1.2 // SKIP_INLINE_CHECK_IN: inlineFun$default -// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS, NATIVE //WITH_RUNTIME package test diff --git a/compiler/testData/codegen/boxInline/reified/capturedLambda2.kt b/compiler/testData/codegen/boxInline/reified/capturedLambda2.kt index f25f1ec8d22..dcc09a82265 100644 --- a/compiler/testData/codegen/boxInline/reified/capturedLambda2.kt +++ b/compiler/testData/codegen/boxInline/reified/capturedLambda2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: NATIVE // FILE: 1.kt // WITH_REFLECT package test diff --git a/compiler/testData/codegen/boxInline/reified/kt15997.kt b/compiler/testData/codegen/boxInline/reified/kt15997.kt index ec3b3ce6ec6..1dab7b85236 100644 --- a/compiler/testData/codegen/boxInline/reified/kt15997.kt +++ b/compiler/testData/codegen/boxInline/reified/kt15997.kt @@ -1,6 +1,7 @@ // FILE: 1.kt // FULL_JDK // WITH_REFLECT +// IGNORE_BACKEND: NATIVE package test import kotlin.properties.Delegates diff --git a/compiler/testData/codegen/boxInline/reified/kt15997_2.kt b/compiler/testData/codegen/boxInline/reified/kt15997_2.kt index e953b847f29..04301fc681c 100644 --- a/compiler/testData/codegen/boxInline/reified/kt15997_2.kt +++ b/compiler/testData/codegen/boxInline/reified/kt15997_2.kt @@ -1,6 +1,7 @@ // FILE: 1.kt // FULL_JDK // WITH_REFLECT +// IGNORE_BACKEND: NATIVE package test import kotlin.properties.Delegates diff --git a/compiler/testData/codegen/boxInline/reified/kt9637_2.kt b/compiler/testData/codegen/boxInline/reified/kt9637_2.kt index c73c2638623..bd2c993cb0c 100644 --- a/compiler/testData/codegen/boxInline/reified/kt9637_2.kt +++ b/compiler/testData/codegen/boxInline/reified/kt9637_2.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: NATIVE // FILE: 1.kt package test diff --git a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt index b730c10e82d..0771be8081d 100644 --- a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt +++ b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt @@ -31,8 +31,8 @@ class ValByMapExtensionsTest { } - class VarByMapExtensionsTest { +// IGNORE_BACKEND: NATIVE val map = hashMapOf("a" to "all", "b" to null, "c" to 1, "xProperty" to 1.0) val map2: MutableMap = hashMapOf("a2" to "all") @@ -66,3 +66,38 @@ class VarByMapExtensionsTest { assertEquals(null, d) } } + +class VarByMapExtensionsTest_ForNative { + val map = hashMapOf("a" to "all", "b" to null, "c" to 1, "xProperty" to 1.0) + val map2: MutableMap = hashMapOf("a2" to "all") + + var a: String by map + var b: Any? by map + var c: Int by map + var d: String? by map + var a2: String by map2.withDefault { "empty" } + //var x: Int by map2 // prohibited by type system + + @Test fun doTest() { + assertEquals("all", a) + assertEquals(null, b) + assertEquals(1, c) + c = 2 + assertEquals(2, c) + assertEquals(2, map["c"]) + + assertEquals("all", a2) + map2.remove("a2") + assertEquals("empty", a2) + + map["c"] = "string" + // fails { c } // does not fail in JS due to KT-8135 + + map["a"] = null + //a Fails in Native, KT-8135 is already fixed in Native. // fails { a } // does not fail due to KT-8135 + + assertFailsWith { d } + map["d"] = null + assertEquals(null, d) + } +}