From 2a19b06874d0af672445a10a231922b64c8ae251 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Wed, 30 Sep 2015 17:09:35 +0300 Subject: [PATCH] new tests --- .../boxInline/argumentOrder/extension.1.kt | 28 +++++++++++++++ .../boxInline/argumentOrder/extension.2.kt | 5 +++ .../argumentOrder/extensionInClass.1.kt | 30 ++++++++++++++++ .../argumentOrder/extensionInClass.2.kt | 7 ++++ .../{justLambda.1.kt => lambdaMigration.1.kt} | 0 .../{justLambda.2.kt => lambdaMigration.2.kt} | 0 .../argumentOrder/lambdaMigrationInClass.1.kt | 19 ++++++++++ .../argumentOrder/lambdaMigrationInClass.2.kt | 9 +++++ .../argumentOrder/simpleInClass.1.kt | 19 ++++++++++ .../argumentOrder/simpleInClass.2.kt | 7 ++++ .../BlackBoxInlineCodegenTestGenerated.java | 36 +++++++++++++++++-- ...otlinAgainstInlineKotlinTestGenerated.java | 36 +++++++++++++++++-- 12 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/extension.1.kt create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/extension.2.kt create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.1.kt create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.2.kt rename compiler/testData/codegen/boxInline/argumentOrder/{justLambda.1.kt => lambdaMigration.1.kt} (100%) rename compiler/testData/codegen/boxInline/argumentOrder/{justLambda.2.kt => lambdaMigration.2.kt} (100%) create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.1.kt create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.2.kt create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.1.kt create mode 100644 compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.2.kt diff --git a/compiler/testData/codegen/boxInline/argumentOrder/extension.1.kt b/compiler/testData/codegen/boxInline/argumentOrder/extension.1.kt new file mode 100644 index 00000000000..7a9178dad16 --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/extension.1.kt @@ -0,0 +1,28 @@ +import test.* + +fun box(): String { + var invokeOrder = ""; + val expectedResult = "1.0_0_1_L" + val expectedInvokeOrder = "1_0_L" + var l = 1L + var i = 0 + + var result = 1.0.test(b = {invokeOrder += "1_"; l}(), a = {invokeOrder+="0_"; i}(), c = {invokeOrder += "L"; "L"}) + if (invokeOrder != expectedInvokeOrder || result != expectedResult) return "fail 1: $invokeOrder != $expectedInvokeOrder or $result != $expectedResult" + + invokeOrder = ""; + result = 1.0.test(b = {invokeOrder += "1_"; l}(), c = {invokeOrder += "L"; "L"}, a = {invokeOrder+="0_"; i}()) + if (invokeOrder != expectedInvokeOrder || result != expectedResult) return "fail 2: $invokeOrder != $expectedInvokeOrder or $result != $expectedResult" + + + invokeOrder = ""; + result = 1.0.test(c = {invokeOrder += "L"; "L"}, b = {invokeOrder += "1_"; l}(), a = {invokeOrder+="0_"; i}()) + if (invokeOrder != expectedInvokeOrder || result != expectedResult) return "fail 3: $invokeOrder != $expectedInvokeOrder or $result != $expectedResult" + + + invokeOrder = ""; + result = 1.0.test(a = {invokeOrder+="0_"; i}(), c = {invokeOrder += "L"; "L"}, b = {invokeOrder += "1_"; l}()) + if (invokeOrder != "0_1_L" || result != expectedResult) return "fail 4: $invokeOrder != 0_1_L or $result != $expectedResult" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/argumentOrder/extension.2.kt b/compiler/testData/codegen/boxInline/argumentOrder/extension.2.kt new file mode 100644 index 00000000000..330b5134a28 --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/extension.2.kt @@ -0,0 +1,5 @@ +package test + +inline fun Double.test(a: Int, b: Long, c: () -> String): String { + return "${this}_${a}_${b}_${c()}" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.1.kt b/compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.1.kt new file mode 100644 index 00000000000..8605b256de6 --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.1.kt @@ -0,0 +1,30 @@ +import test.* + +fun box(): String { + with (Z()) { + var invokeOrder = ""; + val expectedResult = "1.0_0_1_L" + val expectedInvokeOrder = "1_0_L" + var l = 1L + var i = 0 + + var result = 1.0.test(b = { invokeOrder += "1_"; l }(), a = { invokeOrder += "0_"; i }(), c = { invokeOrder += "L"; "L" }) + if (invokeOrder != expectedInvokeOrder || result != expectedResult) return "fail 1: $invokeOrder != $expectedInvokeOrder or $result != $expectedResult" + + invokeOrder = ""; + result = 1.0.test(b = { invokeOrder += "1_"; l }(), c = { invokeOrder += "L"; "L" }, a = { invokeOrder += "0_"; i }()) + if (invokeOrder != expectedInvokeOrder || result != expectedResult) return "fail 2: $invokeOrder != $expectedInvokeOrder or $result != $expectedResult" + + + invokeOrder = ""; + result = 1.0.test(c = { invokeOrder += "L"; "L" }, b = { invokeOrder += "1_"; l }(), a = { invokeOrder += "0_"; i }()) + if (invokeOrder != expectedInvokeOrder || result != expectedResult) return "fail 3: $invokeOrder != $expectedInvokeOrder or $result != $expectedResult" + + + invokeOrder = ""; + result = 1.0.test(a = { invokeOrder += "0_"; i }(), c = { invokeOrder += "L"; "L" }, b = { invokeOrder += "1_"; l }()) + if (invokeOrder != "0_1_L" || result != expectedResult) return "fail 4: $invokeOrder != 0_1_L or $result != $expectedResult" + } + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.2.kt b/compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.2.kt new file mode 100644 index 00000000000..700bb85ee7c --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.2.kt @@ -0,0 +1,7 @@ +package test + +class Z { + inline fun Double.test(a: Int, b: Long, c: () -> String): String { + return "${this}_${a}_${b}_${c()}" + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/argumentOrder/justLambda.1.kt b/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigration.1.kt similarity index 100% rename from compiler/testData/codegen/boxInline/argumentOrder/justLambda.1.kt rename to compiler/testData/codegen/boxInline/argumentOrder/lambdaMigration.1.kt diff --git a/compiler/testData/codegen/boxInline/argumentOrder/justLambda.2.kt b/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigration.2.kt similarity index 100% rename from compiler/testData/codegen/boxInline/argumentOrder/justLambda.2.kt rename to compiler/testData/codegen/boxInline/argumentOrder/lambdaMigration.2.kt diff --git a/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.1.kt b/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.1.kt new file mode 100644 index 00000000000..2e3cd84e63c --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.1.kt @@ -0,0 +1,19 @@ +import test.* + +fun box(): String { + var res = ""; + var call = Z("Z").test(a = {res += "K"; "K"}(), b = {res+="O"; "O"}(), c = {res += "L"; "L"}) + if (res != "KOL" || call != "KOLZ") return "fail 1: $res != KOL or $call != KOLZ" + + res = ""; + call = Z("Z").test(a = {res += "K"; "K"}(), c = {res += "L"; "L"}, b = {res+="O"; "O"}()) + if (res != "KOL" || call != "KOLZ") return "fail 2: $res != KOL or $call != KOLZ" + + + res = ""; + call = Z("Z").test(c = {res += "L"; "L"}, a = {res += "K"; "K"}(), b = {res+="O"; "O"}()) + if (res != "KOL" || call != "KOLZ") return "fail 3: $res != KOL or $call != KOLZ" + + return "OK" + +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.2.kt b/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.2.kt new file mode 100644 index 00000000000..57ddd8644e8 --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.2.kt @@ -0,0 +1,9 @@ +package test + +class Z(val p: String) { + + inline fun test(a: String, b: String, c: () -> String): String { + return a + b + c() + p; + } + +} diff --git a/compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.1.kt b/compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.1.kt new file mode 100644 index 00000000000..e34462e2c41 --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.1.kt @@ -0,0 +1,19 @@ +import test.* + +fun box(): String { + var res = ""; + var call = Z("Z").test(b = {res += "K"; "K"}(), a = {res+="O"; "O"}(), c = {res += "L"; "L"}) + if (res != "KOL" || call != "OKLZ") return "fail 1: $res != KOL or $call != OKLZ" + + res = ""; + call = Z("Z").test(b = {res += "K"; "K"}(), c = {res += "L"; "L"}, a = {res+="O"; "O"}()) + if (res != "KOL" || call != "OKLZ") return "fail 2: $res != KOL or $call != OKLZ" + + + res = ""; + call = Z("Z").test(c = {res += "L"; "L"}, b = {res += "K"; "K"}(), a = {res+="O"; "O"}()) + if (res != "KOL" || call != "OKLZ") return "fail 3: $res != KOL or $call != OKLZ" + + return "OK" + +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.2.kt b/compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.2.kt new file mode 100644 index 00000000000..a15e197692d --- /dev/null +++ b/compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.2.kt @@ -0,0 +1,7 @@ +package test + +class Z(val p: String) { + inline fun test(a: String, b: String, c: () -> String): String { + return a + b + c() + p; + } +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java index a1f15398e76..216f42935b0 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java @@ -124,9 +124,33 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/argumentOrder"), Pattern.compile("^(.+)\\.1.kt$"), true); } - @TestMetadata("justLambda.1.kt") - public void testJustLambda() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/justLambda.1.kt"); + @TestMetadata("captured.1.kt") + public void testCaptured() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/captured.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("extension.1.kt") + public void testExtension() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/extension.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("extensionInClass.1.kt") + public void testExtensionInClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("lambdaMigration.1.kt") + public void testLambdaMigration() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/lambdaMigration.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("lambdaMigrationInClass.1.kt") + public void testLambdaMigrationInClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.1.kt"); doTestMultiFileWithInlineCheck(fileName); } @@ -135,6 +159,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/simple.1.kt"); doTestMultiFileWithInlineCheck(fileName); } + + @TestMetadata("simpleInClass.1.kt") + public void testSimpleInClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } } @TestMetadata("compiler/testData/codegen/boxInline/builders") diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java index 2af3892b29e..939279da666 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -124,9 +124,33 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/argumentOrder"), Pattern.compile("^(.+)\\.1.kt$"), true); } - @TestMetadata("justLambda.1.kt") - public void testJustLambda() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/justLambda.1.kt"); + @TestMetadata("captured.1.kt") + public void testCaptured() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/captured.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("extension.1.kt") + public void testExtension() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/extension.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("extensionInClass.1.kt") + public void testExtensionInClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/extensionInClass.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("lambdaMigration.1.kt") + public void testLambdaMigration() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/lambdaMigration.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("lambdaMigrationInClass.1.kt") + public void testLambdaMigrationInClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/lambdaMigrationInClass.1.kt"); doBoxTestWithInlineCheck(fileName); } @@ -135,6 +159,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/simple.1.kt"); doBoxTestWithInlineCheck(fileName); } + + @TestMetadata("simpleInClass.1.kt") + public void testSimpleInClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/argumentOrder/simpleInClass.1.kt"); + doBoxTestWithInlineCheck(fileName); + } } @TestMetadata("compiler/testData/codegen/boxInline/builders")