JetLiteFixture: assign to myEnvironment only once

This commit is contained in:
Stepan Koltsov
2012-05-01 22:32:08 +04:00
parent 0c7401c932
commit c23feab6d1
34 changed files with 289 additions and 11 deletions
@@ -31,6 +31,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testIf() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
@@ -40,6 +41,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testSingleBranchIf() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
@@ -61,6 +63,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
private void factorialTest(final String name) throws IllegalAccessException, InvocationTargetException {
createEnvironmentWithMockJdk();
loadFile(name);
// System.out.println(generateToText());
@@ -70,6 +73,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testContinue() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -78,6 +82,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testIfNoElse() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -86,6 +91,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testCondJumpOnStack() throws Exception {
createEnvironmentWithMockJdk();
loadText("import java.lang.Boolean as jlBoolean; fun foo(a: String): Int = if (jlBoolean.parseBoolean(a)) 5 else 10");
final Method main = generateFunction();
assertEquals(5, main.invoke(null, "true"));
@@ -93,6 +99,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testFor() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -101,6 +108,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testIfBlock() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -111,6 +119,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testForInArray() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -119,6 +128,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testForInRange() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(sb: StringBuilder) { for(x in 1..4) sb.append(x) }");
final Method main = generateFunction();
StringBuilder stringBuilder = new StringBuilder();
@@ -127,6 +137,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testThrowCheckedException() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo() { throw Exception(); }");
final Method main = generateFunction();
boolean caught = false;
@@ -141,6 +152,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testTryCatch() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -149,6 +161,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testTryFinally() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -168,30 +181,37 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testForUserType() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forUserType.jet");
}
public void testForIntArray() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forIntArray.jet");
}
public void testForPrimitiveIntArray() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forPrimitiveIntArray.jet");
}
public void testForNullableIntArray() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forNullableIntArray.jet");
}
public void testForIntRange() {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forIntRange.jet");
}
public void testKt237() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt237.jet");
}
public void testCompareToNull() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(a: String?, b: String?): Boolean = a == null && b !== null && null == a && null !== b");
String text = generateToText();
assertTrue(!text.contains("java/lang/Object.equals"));
@@ -202,6 +222,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testCompareToNonnullableEq() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(a: String?, b: String): Boolean = a == b || b == a");
// System.out.println(generateToText());
final Method main = generateFunction();
@@ -210,6 +231,7 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testCompareToNonnullableNotEq() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(a: String?, b: String): Boolean = a != b");
String text = generateToText();
// System.out.println(text);
@@ -220,15 +242,18 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testKt299() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt299.jet");
}
public void testKt416() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt416.jet");
// System.out.println(generateToText());
}
public void testKt513() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt513.jet");
}
@@ -238,31 +263,37 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testKt769() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt769.jet");
// System.out.println(generateToText());
}
public void testKt773() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt773.jet");
// System.out.println(generateToText());
}
public void testKt772() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt772.jet");
// System.out.println(generateToText());
}
public void testKt870() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt870.jet");
// System.out.println(generateToText());
}
public void testKt958() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt958.jet");
// System.out.println(generateToText());
}
public void testQuicksort() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/quicksort.jet");
// System.out.println(generateToText());
}
@@ -280,18 +311,22 @@ public class ControlStructuresTest extends CodegenTestCase {
}
public void testKt1076() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1076.kt");
}
public void testKt998() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt998.kt");
}
public void testKt628() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt628.kt");
}
public void testKt1441() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1441.kt");
}
}