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 PropertyGenTest extends CodegenTestCase {
}
public void testPrivateVal() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVal");
final Field[] fields = aClass.getDeclaredFields();
@@ -40,6 +41,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testPrivateVar() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVar");
final Object instance = aClass.newInstance();
@@ -50,6 +52,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testPublicVar() throws Exception {
createEnvironmentWithMockJdk();
loadText("class PublicVar() { public var foo : Int = 0; }");
final Class aClass = loadImplementationClass(generateClassesInFile(), "PublicVar");
final Object instance = aClass.newInstance();
@@ -60,6 +63,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testAccessorsInInterface() {
createEnvironmentWithMockJdk();
loadText("class AccessorsInInterface() { public var foo : Int = 0; }");
final Class aClass = loadClass("AccessorsInInterface", generateClassesInFile());
assertNotNull(findMethodByName(aClass, "getFoo"));
@@ -67,6 +71,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testPrivatePropertyInNamespace() throws Exception {
createEnvironmentWithMockJdk();
loadText("private val x = 239");
final Class nsClass = generateNamespaceClass();
final Field[] fields = nsClass.getDeclaredFields();
@@ -79,6 +84,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testFieldPropertyAccess() throws Exception {
createEnvironmentWithMockJdk();
loadFile("properties/fieldPropertyAccess.jet");
// System.out.println(generateToText());
final Method method = generateFunction();
@@ -87,12 +93,14 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testFieldGetter() throws Exception {
createEnvironmentWithMockJdk();
loadText("val now: Long get() = System.currentTimeMillis(); fun foo() = now");
final Method method = generateFunction("foo");
assertIsCurrentTime((Long) method.invoke(null));
}
public void testFieldSetter() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
final Method method = generateFunction("append");
method.invoke(null, "IntelliJ ");
@@ -104,6 +112,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testFieldSetterPlusEq() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
final Method method = generateFunction("append");
method.invoke(null, "IntelliJ ");
@@ -112,6 +121,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testAccessorsWithoutBody() throws Exception {
createEnvironmentWithMockJdk();
loadText("class AccessorsWithoutBody() { protected var foo: Int = 349\n get\n private set\n fun setter() { foo = 610; } } ");
// System.out.println(generateToText());
final Class aClass = loadImplementationClass(generateClassesInFile(), "AccessorsWithoutBody");
@@ -129,6 +139,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testInitializersForNamespaceProperties() throws Exception {
createEnvironmentWithMockJdk();
loadText("val x = System.currentTimeMillis()");
final Method method = generateFunction("getX");
method.setAccessible(true);
@@ -136,6 +147,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testPropertyReceiverOnStack() throws Exception {
createEnvironmentWithMockJdk();
loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "Evaluator");
final Constructor constructor = aClass.getConstructor(StringBuilder.class);
@@ -147,6 +159,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testAbstractVal() throws Exception {
createEnvironmentWithMockJdk();
loadText("abstract class Foo { public abstract val x: String }");
final ClassFileFactory codegens = generateClassesInFile();
final Class aClass = loadClass("Foo", codegens);
@@ -154,6 +167,7 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testVolatileProperty() throws Exception {
createEnvironmentWithMockJdk();
loadText("abstract class Foo { public volatile var x: String = \"\"; }");
// System.out.println(generateToText());
final ClassFileFactory codegens = generateClassesInFile();
@@ -163,15 +177,18 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testKt257 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt257.jet");
// System.out.println(generateToText());
}
public void testKt613 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt613.jet");
}
public void testKt160() throws Exception {
createEnvironmentWithMockJdk();
loadText("internal val s = java.lang.Double.toString(1.0)");
final Method method = generateFunction("getS");
method.setAccessible(true);
@@ -179,10 +196,12 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testKt1165() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1165.kt");
}
public void testKt1168() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1168.kt");
}
@@ -192,14 +211,17 @@ public class PropertyGenTest extends CodegenTestCase {
}
public void testKt1159() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1159.kt");
}
public void testKt1417() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1417.kt");
}
public void testKt1398() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1398.kt");
}