Added new string tests
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fun test(p: String?): String {
|
||||
return "${p ?: "Default"} test"
|
||||
}
|
||||
fun box(): String {
|
||||
if (test(null) != "Default test") return "fail 1: ${test(null)}"
|
||||
if (test("Good") != "Good test") return "fail 1: ${test("OK")}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "A"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
|
||||
val s = "1" plus "2" plus 3 plus 4L plus 5.0 plus 6F plus '7' plus A()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
/*TODO:
|
||||
1 NEW java/lang/StringBuilder*/
|
||||
@@ -0,0 +1,16 @@
|
||||
class A() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "A"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
val p = 1
|
||||
val s = "${p}${2}${3}${4L}${5.0}${6F}${7}${A()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 1 NEW java/lang/StringBuilder
|
||||
@@ -0,0 +1,16 @@
|
||||
class A() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "A"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
var s = "1"
|
||||
s += "2" + 3 + 4L + 5.0 + 6F + '7' + A()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 1 NEW java/lang/StringBuilder
|
||||
@@ -42,6 +42,7 @@ import java.util.regex.Pattern;
|
||||
BytecodeTextTestGenerated.Statements.class,
|
||||
BytecodeTextTestGenerated.StaticFields.class,
|
||||
BytecodeTextTestGenerated.StoreStackBeforeInline.class,
|
||||
BytecodeTextTestGenerated.StringOperations.class,
|
||||
BytecodeTextTestGenerated.When.class,
|
||||
BytecodeTextTestGenerated.WhenEnumOptimization.class,
|
||||
BytecodeTextTestGenerated.WhenStringOptimization.class,
|
||||
@@ -208,12 +209,6 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("stringBuilderAppend.kt")
|
||||
public void testStringBuilderAppend() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringBuilderAppend.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunWithDefaultArgs.kt")
|
||||
public void testTopLevelFunWithDefaultArgs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt");
|
||||
@@ -661,6 +656,39 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/stringOperations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class StringOperations extends AbstractBytecodeTextTest {
|
||||
public void testAllFilesPresentInStringOperations() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/stringOperations"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("concat.kt")
|
||||
public void testConcat() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/concat.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("infixPlus.kt")
|
||||
public void testInfixPlus() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/infixPlus.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("interpolation.kt")
|
||||
public void testInterpolation() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/interpolation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("plusAssign.kt")
|
||||
public void testPlusAssign() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/plusAssign.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/when")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+6
@@ -6525,6 +6525,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("interpolation.kt")
|
||||
public void testInterpolation() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/interpolation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2592.kt")
|
||||
public void testKt2592() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/kt2592.kt");
|
||||
|
||||
Reference in New Issue
Block a user