new tests

This commit is contained in:
Michael Bogdanov
2015-09-30 17:09:35 +03:00
parent c83a5b8bd5
commit 2a19b06874
12 changed files with 190 additions and 6 deletions
@@ -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"
}
@@ -0,0 +1,5 @@
package test
inline fun Double.test(a: Int, b: Long, c: () -> String): String {
return "${this}_${a}_${b}_${c()}"
}
@@ -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"
}
@@ -0,0 +1,7 @@
package test
class Z {
inline fun Double.test(a: Int, b: Long, c: () -> String): String {
return "${this}_${a}_${b}_${c()}"
}
}
@@ -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"
}
@@ -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;
}
}
@@ -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"
}
@@ -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;
}
}
@@ -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")
@@ -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")