Script refactoring, codegen tests: change test data according to semantics change

Add some new tests for uncovered cases
This commit is contained in:
Pavel V. Talanov
2015-11-17 15:14:15 +03:00
parent 6563830584
commit ad58617753
22 changed files with 42 additions and 26 deletions
+5
View File
@@ -0,0 +1,5 @@
var x = 0
x++
x++
x++
// expected: x: 3
+1 -2
View File
@@ -1,2 +1 @@
// expected: rv: null
// expected: rv: <nofield>
+2 -2
View File
@@ -1,2 +1,2 @@
// expected: rv: null
System.out!!.println("hello world")
// expected: rv: <nofield>
System.out!!.println("hello world")
+1 -1
View File
@@ -11,4 +11,4 @@ fun main(): Int {
return foo { x -> bar(x) }
}
main()
val rv = main()
+1 -1
View File
@@ -11,4 +11,4 @@ fun main(): Int {
return foo { x -> bar(x) }
}
main()
val rv = main()
+1 -1
View File
@@ -2,4 +2,4 @@
// param: what: kotlin.String: sky
// param: color: kotlin.String: blue
"$what color is $color"
val rv = "$what color is $color"
+1 -1
View File
@@ -1,4 +1,4 @@
// param: args: kotlin.Array<kotlin.String>: three little words
// expected: rv: little
args[1]
val rv = args[1]
+1 -1
View File
@@ -2,6 +2,6 @@
fun addX(y: Int) = x + y
addX(3)
val rv = addX(3)
// expected: rv: 13
+1 -1
View File
@@ -2,4 +2,4 @@
// param: aa: kotlin.Long: 17
// param: bb: kotlin.Int: 2
aa + bb
val rv = aa + bb
+2 -2
View File
@@ -1,10 +1,10 @@
val x: Int
var x: Int = 0
if (true) {
fun foo(y: Int) = y + 20
x = foo(9)
}
x
val rv = x
// expected: rv: 29
@@ -1,11 +1,11 @@
val z = 30
val x: Int
var x: Int = 0
if (true) {
fun foo() = z + 20
x = foo()
}
x
val rv = x
// expected: rv: 50
-3
View File
@@ -2,7 +2,4 @@ if (true) {
val archenemy = "Jim Moriarty"
}
true
// expected: rv: true
// expected: archenemy: <nofield>
+1 -1
View File
@@ -2,6 +2,6 @@ class SimpleClass(val s: String) {
fun foo() = s
}
SimpleClass("OK").foo()
val rv = SimpleClass("OK").foo()
// expected: rv: OK
+1 -1
View File
@@ -1,3 +1,3 @@
"O" + "K"
val rv = "O" + "K"
// expected: rv: OK
+1 -1
View File
@@ -8,4 +8,4 @@ fun factorial(n: Int): Int {
return product
}
factorial(10)
val rv = factorial(10)
@@ -2,6 +2,6 @@ val x = 12
fun foo(y: Int) = x + y
foo(33)
val rv = foo(33)
// expected: rv: 45
+1 -2
View File
@@ -1,4 +1,3 @@
val fibwp = test.Fibwp(5)
val callResult = fibwp.fib(4)
val result = fibwp.num + fibwp.result - 5
fibwp.rv
val result = fibwp.num + fibwp.result - 5
+1 -1
View File
@@ -1,6 +1,6 @@
>>> fun foo() = 765
>>> foo(1)
error: too many arguments for public final fun foo(): kotlin.Int defined in <script>
error: too many arguments for public final fun foo(): kotlin.Int defined in Line1
foo(1)
^
>>> foo()
@@ -0,0 +1,6 @@
>>> val c = "OK"
>>> inner class A {
... fun foo() = c
... }
>>> A().foo()
OK
@@ -31,6 +31,12 @@ import java.util.regex.Pattern;
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class ScriptCodegenTestGenerated extends AbstractScriptCodegenTest {
@TestMetadata("adder.kts")
public void testAdder() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/adder.kts");
doTest(fileName);
}
public void testAllFilesPresentInScript() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/script"), Pattern.compile("^(.+)\\.kts$"), true);
}
@@ -69,10 +69,8 @@ public class ScriptGenTest extends CodegenTestCase {
Method resultMethod = aClass.getDeclaredMethod("getResult");
assertTrue((resultMethod.getModifiers() & Opcodes.ACC_FINAL) != 0);
assertTrue((resultMethod.getModifiers() & Opcodes.ACC_PUBLIC) != 0);
Field rv = aClass.getField("rv");
assertTrue((result.getModifiers() & Opcodes.ACC_PRIVATE) != 0);
Object script = constructor.newInstance();
assertEquals(12, rv.get(script));
assertEquals(8, result.get(script));
assertEquals(8, resultMethod.invoke(script));
}
@@ -133,6 +133,12 @@ public class ReplInterpreterTestGenerated extends AbstractReplInterpreterTest {
doTest(fileName);
}
@TestMetadata("classReferencesVal.repl")
public void testClassReferencesVal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/repl/classes/classReferencesVal.repl");
doTest(fileName);
}
@TestMetadata("emptyClass.repl")
public void testEmptyClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/repl/classes/emptyClass.repl");