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
@@ -30,8 +30,10 @@ import com.intellij.testFramework.LightVirtualFile;
import com.intellij.testFramework.TestDataFile; import com.intellij.testFramework.TestDataFile;
import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.UsefulTestCase;
import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
import org.jetbrains.jet.plugin.JetLanguage; import org.jetbrains.jet.plugin.JetLanguage;
import java.io.File; import java.io.File;
@@ -65,14 +67,19 @@ public abstract class JetLiteFixture extends UsefulTestCase {
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
createEnvironmentWithMockJdk();
} }
protected void createEnvironmentWithMockJdk() { protected void createEnvironmentWithMockJdk() {
if (myEnvironment != null) {
throw new IllegalStateException("must not set up myEnvironemnt twice");
}
myEnvironment = JetTestUtils.createEnvironmentWithMockJdk(getTestRootDisposable()); myEnvironment = JetTestUtils.createEnvironmentWithMockJdk(getTestRootDisposable());
} }
protected void createEnvironmentWithFullJdk() { protected void createEnvironmentWithFullJdk() {
if (myEnvironment != null) {
throw new IllegalStateException("must not set up myEnvironemnt twice");
}
myEnvironment = JetTestUtils.createEnvironmentWithFullJdk(getTestRootDisposable()); myEnvironment = JetTestUtils.createEnvironmentWithFullJdk(getTestRootDisposable());
} }
@@ -42,7 +42,7 @@ public class JetControlFlowTest extends JetLiteFixture {
static { static {
System.setProperty("idea.platform.prefix", "Idea"); System.setProperty("idea.platform.prefix", "Idea");
} }
private String myName; private String myName;
public JetControlFlowTest(String dataPath, String name) { public JetControlFlowTest(String dataPath, String name) {
@@ -50,6 +50,13 @@ public class JetControlFlowTest extends JetLiteFixture {
myName = name; myName = name;
} }
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
@Override @Override
public String getName() { public String getName() {
return "test" + myName; return "test" + myName;
@@ -40,6 +40,13 @@ public class CheckerTestUtilTest extends JetLiteFixture {
super("diagnostics/checkerTestUtil"); super("diagnostics/checkerTestUtil");
} }
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
protected void doTest(TheTest theTest) throws Exception { protected void doTest(TheTest theTest) throws Exception {
prepareForTest("test"); prepareForTest("test");
theTest.test(myFile); theTest.test(myFile);
@@ -54,6 +54,12 @@ public class JetDiagnosticsTest extends JetLiteFixture {
this.name = name; this.name = name;
} }
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
@Override @Override
public String getName() { public String getName() {
return "test" + name; return "test" + name;
@@ -24,6 +24,13 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class AnnotationGenTest extends CodegenTestCase { public class AnnotationGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testPropField() throws NoSuchFieldException, NoSuchMethodException { public void testPropField() throws NoSuchFieldException, NoSuchMethodException {
loadText("[Deprecated] var x = 0"); loadText("[Deprecated] var x = 0");
Class aClass = generateNamespaceClass(); Class aClass = generateNamespaceClass();
@@ -19,6 +19,13 @@ package org.jetbrains.jet.codegen;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class ArrayGenTest extends CodegenTestCase { public class ArrayGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testKt238 () throws Exception { public void testKt238 () throws Exception {
blackBoxFile("regressions/kt238.jet"); blackBoxFile("regressions/kt238.jet");
} }
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen;
public class BridgeMethodGenTest extends CodegenTestCase { public class BridgeMethodGenTest extends CodegenTestCase {
public void testBridgeMethod () throws Exception { public void testBridgeMethod () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("bridge.jet"); blackBoxFile("bridge.jet");
} }
} }
@@ -26,7 +26,14 @@ import java.util.List;
* @author alex.tkachman * @author alex.tkachman
*/ */
public class ClassGenTest extends CodegenTestCase { public class ClassGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
public void testPSVMClass() throws Exception { public void testPSVMClass() throws Exception {
createEnvironmentWithMockJdk();
loadFile("classes/simpleClass.jet"); loadFile("classes/simpleClass.jet");
final Class aClass = loadClass("SimpleClass", generateClassesInFile()); final Class aClass = loadClass("SimpleClass", generateClassesInFile());
@@ -37,6 +44,7 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testArrayListInheritance() throws Exception { public void testArrayListInheritance() throws Exception {
createEnvironmentWithMockJdk();
loadFile("classes/inheritingFromArrayList.jet"); loadFile("classes/inheritingFromArrayList.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Class aClass = loadClass("Foo", generateClassesInFile()); final Class aClass = loadClass("Foo", generateClassesInFile());
@@ -44,30 +52,37 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testInheritanceAndDelegation_DelegatingDefaultConstructorProperties() throws Exception { public void testInheritanceAndDelegation_DelegatingDefaultConstructorProperties() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/inheritance.jet"); blackBoxFile("classes/inheritance.jet");
} }
public void testInheritanceAndDelegation2() throws Exception { public void testInheritanceAndDelegation2() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/delegation2.kt"); blackBoxFile("classes/delegation2.kt");
} }
public void testFunDelegation() throws Exception { public void testFunDelegation() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/funDelegation.jet"); blackBoxFile("classes/funDelegation.jet");
} }
public void testPropertyDelegation() throws Exception { public void testPropertyDelegation() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/propertyDelegation.jet"); blackBoxFile("classes/propertyDelegation.jet");
} }
public void testDiamondInheritance() throws Exception { public void testDiamondInheritance() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/diamondInheritance.jet"); blackBoxFile("classes/diamondInheritance.jet");
} }
public void testRightHandOverride() throws Exception { public void testRightHandOverride() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/rightHandOverride.jet"); blackBoxFile("classes/rightHandOverride.jet");
} }
public void testNewInstanceExplicitConstructor() throws Exception { public void testNewInstanceExplicitConstructor() throws Exception {
createEnvironmentWithMockJdk();
loadFile("classes/newInstanceDefaultConstructor.jet"); loadFile("classes/newInstanceDefaultConstructor.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method method = generateFunction("test"); final Method method = generateFunction("test");
@@ -76,18 +91,22 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testInnerClass() throws Exception { public void testInnerClass() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/innerClass.jet"); blackBoxFile("classes/innerClass.jet");
} }
public void testInheritedInnerClass() throws Exception { public void testInheritedInnerClass() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/inheritedInnerClass.jet"); blackBoxFile("classes/inheritedInnerClass.jet");
} }
public void testInitializerBlock() throws Exception { public void testInitializerBlock() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/initializerBlock.jet"); blackBoxFile("classes/initializerBlock.jet");
} }
public void testAbstractMethod() throws Exception { public void testAbstractMethod() throws Exception {
createEnvironmentWithMockJdk();
loadText("abstract class Foo { abstract fun x(): String; fun y(): Int = 0 }"); loadText("abstract class Foo { abstract fun x(): String; fun y(): Int = 0 }");
final ClassFileFactory codegens = generateClassesInFile(); final ClassFileFactory codegens = generateClassesInFile();
@@ -97,34 +116,42 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testInheritedMethod() throws Exception { public void testInheritedMethod() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/inheritedMethod.jet"); blackBoxFile("classes/inheritedMethod.jet");
} }
public void testInitializerBlockDImpl() throws Exception { public void testInitializerBlockDImpl() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/initializerBlockDImpl.jet"); blackBoxFile("classes/initializerBlockDImpl.jet");
} }
public void testPropertyInInitializer() throws Exception { public void testPropertyInInitializer() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/propertyInInitializer.jet"); blackBoxFile("classes/propertyInInitializer.jet");
} }
public void testOuterThis() throws Exception { public void testOuterThis() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/outerThis.jet"); blackBoxFile("classes/outerThis.jet");
} }
public void testSecondaryConstructors() throws Exception { public void testSecondaryConstructors() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/secondaryConstructors.jet"); blackBoxFile("classes/secondaryConstructors.jet");
} }
public void testExceptionConstructor() throws Exception { public void testExceptionConstructor() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/exceptionConstructor.jet"); blackBoxFile("classes/exceptionConstructor.jet");
} }
public void testSimpleBox() throws Exception { public void testSimpleBox() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/simpleBox.jet"); blackBoxFile("classes/simpleBox.jet");
} }
public void testAbstractClass() throws Exception { public void testAbstractClass() throws Exception {
createEnvironmentWithMockJdk();
loadText("abstract class SimpleClass() { }"); loadText("abstract class SimpleClass() { }");
final Class aClass = createClassLoader(generateClassesInFile()).loadClass("SimpleClass"); final Class aClass = createClassLoader(generateClassesInFile()).loadClass("SimpleClass");
@@ -132,15 +159,18 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testClassObject() throws Exception { public void testClassObject() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/classObject.jet"); blackBoxFile("classes/classObject.jet");
} }
public void testClassObjectMethod() throws Exception { public void testClassObjectMethod() throws Exception {
// todo to be implemented after removal of type info createEnvironmentWithMockJdk();
// todo to be implemented after removal of type info
// blackBoxFile("classes/classObjectMethod.jet"); // blackBoxFile("classes/classObjectMethod.jet");
} }
public void testClassObjectInterface() throws Exception { public void testClassObjectInterface() throws Exception {
createEnvironmentWithMockJdk();
loadFile("classes/classObjectInterface.jet"); loadFile("classes/classObjectInterface.jet");
final Method method = generateFunction(); final Method method = generateFunction();
Object result = method.invoke(null); Object result = method.invoke(null);
@@ -148,26 +178,32 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testOverloadBinaryOperator() throws Exception { public void testOverloadBinaryOperator() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/overloadBinaryOperator.jet"); blackBoxFile("classes/overloadBinaryOperator.jet");
} }
public void testOverloadUnaryOperator() throws Exception { public void testOverloadUnaryOperator() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/overloadUnaryOperator.jet"); blackBoxFile("classes/overloadUnaryOperator.jet");
} }
public void testOverloadPlusAssign() throws Exception { public void testOverloadPlusAssign() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/overloadPlusAssign.jet"); blackBoxFile("classes/overloadPlusAssign.jet");
} }
public void testOverloadPlusAssignReturn() throws Exception { public void testOverloadPlusAssignReturn() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/overloadPlusAssignReturn.jet"); blackBoxFile("classes/overloadPlusAssignReturn.jet");
} }
public void testOverloadPlusToPlusAssign() throws Exception { public void testOverloadPlusToPlusAssign() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/overloadPlusToPlusAssign.jet"); blackBoxFile("classes/overloadPlusToPlusAssign.jet");
} }
public void testEnumClass() throws Exception { public void testEnumClass() throws Exception {
createEnvironmentWithMockJdk();
loadText("enum class Direction { NORTH; SOUTH; EAST; WEST }"); loadText("enum class Direction { NORTH; SOUTH; EAST; WEST }");
final Class direction = createClassLoader(generateClassesInFile()).loadClass("Direction"); final Class direction = createClassLoader(generateClassesInFile()).loadClass("Direction");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -177,6 +213,7 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testEnumConstantConstructors() throws Exception { public void testEnumConstantConstructors() throws Exception {
createEnvironmentWithMockJdk();
loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }"); loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }");
final Class colorClass = createClassLoader(generateClassesInFile()).loadClass("Color"); final Class colorClass = createClassLoader(generateClassesInFile()).loadClass("Color");
final Field redField = colorClass.getField("RED"); final Field redField = colorClass.getField("RED");
@@ -186,21 +223,25 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testClassObjFields() throws Exception { public void testClassObjFields() throws Exception {
createEnvironmentWithMockJdk();
loadText("class A() { class object { val value = 10 } }\n" + loadText("class A() { class object { val value = 10 } }\n" +
"fun box() = if(A.value == 10) \"OK\" else \"fail\""); "fun box() = if(A.value == 10) \"OK\" else \"fail\"");
blackBox(); blackBox();
} }
public void testKt249() throws Exception { public void testKt249() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt249.jet"); blackBoxFile("regressions/kt249.jet");
} }
public void testKt48 () throws Exception { public void testKt48 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt48.jet"); blackBoxFile("regressions/kt48.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt309 () throws Exception { public void testKt309 () throws Exception {
createEnvironmentWithMockJdk();
loadText("fun box() = null"); loadText("fun box() = null");
final Method method = generateFunction("box"); final Method method = generateFunction("box");
assertEquals(method.getReturnType().getName(), "java.lang.Object"); assertEquals(method.getReturnType().getName(), "java.lang.Object");
@@ -208,65 +249,78 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testKt343 () throws Exception { public void testKt343 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt343.jet"); blackBoxFile("regressions/kt343.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt508 () throws Exception { public void testKt508 () throws Exception {
createEnvironmentWithMockJdk();
loadFile("regressions/kt508.jet"); loadFile("regressions/kt508.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
blackBox(); blackBox();
} }
public void testKt504 () throws Exception { public void testKt504 () throws Exception {
createEnvironmentWithMockJdk();
loadFile("regressions/kt504.jet"); loadFile("regressions/kt504.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
blackBox(); blackBox();
} }
public void testKt501 () throws Exception { public void testKt501 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt501.jet"); blackBoxFile("regressions/kt501.jet");
} }
public void testKt496 () throws Exception { public void testKt496 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt496.jet"); blackBoxFile("regressions/kt496.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt500 () throws Exception { public void testKt500 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt500.jet"); blackBoxFile("regressions/kt500.jet");
} }
public void testKt694 () throws Exception { public void testKt694 () throws Exception {
// blackBoxFile("regressions/kt694.jet"); createEnvironmentWithMockJdk();
// blackBoxFile("regressions/kt694.jet");
} }
public void testKt285 () throws Exception { public void testKt285 () throws Exception {
// blackBoxFile("regressions/kt285.jet"); createEnvironmentWithMockJdk();
// blackBoxFile("regressions/kt285.jet");
} }
public void testKt707 () throws Exception { public void testKt707 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt707.jet"); blackBoxFile("regressions/kt707.jet");
} }
public void testKt857 () throws Exception { public void testKt857 () throws Exception {
// blackBoxFile("regressions/kt857.jet"); createEnvironmentWithMockJdk();
// blackBoxFile("regressions/kt857.jet");
} }
public void testKt903 () throws Exception { public void testKt903 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt903.jet"); blackBoxFile("regressions/kt903.jet");
} }
public void testKt940 () throws Exception { public void testKt940 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt940.kt"); blackBoxFile("regressions/kt940.kt");
} }
public void testKt1018 () throws Exception { public void testKt1018 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1018.kt"); blackBoxFile("regressions/kt1018.kt");
} }
public void testKt1120 () throws Exception { public void testKt1120 () throws Exception {
// createEnvironmentWithFullJdk(); createEnvironmentWithFullJdk();
// blackBoxFile("regressions/kt1120.kt"); // blackBoxFile("regressions/kt1120.kt");
} }
@@ -276,47 +330,58 @@ public class ClassGenTest extends CodegenTestCase {
} }
public void testKt1134() throws Exception { public void testKt1134() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1134.kt"); blackBoxFile("regressions/kt1134.kt");
} }
public void testKt1157() throws Exception { public void testKt1157() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1157.kt"); blackBoxFile("regressions/kt1157.kt");
} }
public void testKt471() throws Exception { public void testKt471() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt471.kt"); blackBoxFile("regressions/kt471.kt");
} }
public void testKt1213() throws Exception { public void testKt1213() throws Exception {
// blackBoxFile("regressions/kt1213.kt"); createEnvironmentWithMockJdk();
// blackBoxFile("regressions/kt1213.kt");
} }
public void testKt723() throws Exception { public void testKt723() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt723.kt"); blackBoxFile("regressions/kt723.kt");
} }
public void testKt725() throws Exception { public void testKt725() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt725.kt"); blackBoxFile("regressions/kt725.kt");
} }
public void testKt633() throws Exception { public void testKt633() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt633.kt"); blackBoxFile("regressions/kt633.kt");
} }
public void testKt1345() throws Exception { public void testKt1345() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1345.kt"); blackBoxFile("regressions/kt1345.kt");
} }
public void testKt1538() throws Exception { public void testKt1538() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1538.kt"); blackBoxFile("regressions/kt1538.kt");
} }
public void testKt1759() throws Exception { public void testKt1759() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1759.kt"); blackBoxFile("regressions/kt1759.kt");
} }
public void testResolveOrder() throws Exception { public void testResolveOrder() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("classes/resolveOrder.jet"); blackBoxFile("classes/resolveOrder.jet");
} }
} }
@@ -20,6 +20,13 @@ package org.jetbrains.jet.codegen;
* @author max * @author max
*/ */
public class ClosuresGenTest extends CodegenTestCase { public class ClosuresGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testSimplestClosure() throws Exception { public void testSimplestClosure() throws Exception {
blackBoxFile("classes/simplestClosure.jet"); blackBoxFile("classes/simplestClosure.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -24,6 +24,7 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode; import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
import org.jetbrains.jet.parsing.JetParsingTest; import org.jetbrains.jet.parsing.JetParsingTest;
@@ -30,6 +30,7 @@ import java.lang.reflect.Method;
public class CompileTextTest extends CodegenTestCase { public class CompileTextTest extends CodegenTestCase {
public void testMe() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { public void testMe() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()"; String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
CompilerDependencies dependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false); CompilerDependencies dependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false);
JetCoreEnvironment environment = new JetCoreEnvironment(CompileEnvironmentUtil.createMockDisposable(), dependencies); JetCoreEnvironment environment = new JetCoreEnvironment(CompileEnvironmentUtil.createMockDisposable(), dependencies);
@@ -31,6 +31,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testIf() throws Exception { public void testIf() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -40,6 +41,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testSingleBranchIf() throws Exception { public void testSingleBranchIf() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -61,6 +63,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
private void factorialTest(final String name) throws IllegalAccessException, InvocationTargetException { private void factorialTest(final String name) throws IllegalAccessException, InvocationTargetException {
createEnvironmentWithMockJdk();
loadFile(name); loadFile(name);
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -70,6 +73,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testContinue() throws Exception { public void testContinue() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -78,6 +82,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testIfNoElse() throws Exception { public void testIfNoElse() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -86,6 +91,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testCondJumpOnStack() throws Exception { 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"); loadText("import java.lang.Boolean as jlBoolean; fun foo(a: String): Int = if (jlBoolean.parseBoolean(a)) 5 else 10");
final Method main = generateFunction(); final Method main = generateFunction();
assertEquals(5, main.invoke(null, "true")); assertEquals(5, main.invoke(null, "true"));
@@ -93,6 +99,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testFor() throws Exception { public void testFor() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -101,6 +108,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testIfBlock() throws Exception { public void testIfBlock() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -111,6 +119,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testForInArray() throws Exception { public void testForInArray() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -119,6 +128,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testForInRange() throws Exception { public void testForInRange() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(sb: StringBuilder) { for(x in 1..4) sb.append(x) }"); loadText("fun foo(sb: StringBuilder) { for(x in 1..4) sb.append(x) }");
final Method main = generateFunction(); final Method main = generateFunction();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
@@ -127,6 +137,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testThrowCheckedException() throws Exception { public void testThrowCheckedException() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo() { throw Exception(); }"); loadText("fun foo() { throw Exception(); }");
final Method main = generateFunction(); final Method main = generateFunction();
boolean caught = false; boolean caught = false;
@@ -141,6 +152,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testTryCatch() throws Exception { public void testTryCatch() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -149,6 +161,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testTryFinally() throws Exception { public void testTryFinally() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -168,30 +181,37 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testForUserType() throws Exception { public void testForUserType() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forUserType.jet"); blackBoxFile("controlStructures/forUserType.jet");
} }
public void testForIntArray() throws Exception { public void testForIntArray() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forIntArray.jet"); blackBoxFile("controlStructures/forIntArray.jet");
} }
public void testForPrimitiveIntArray() throws Exception { public void testForPrimitiveIntArray() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forPrimitiveIntArray.jet"); blackBoxFile("controlStructures/forPrimitiveIntArray.jet");
} }
public void testForNullableIntArray() throws Exception { public void testForNullableIntArray() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forNullableIntArray.jet"); blackBoxFile("controlStructures/forNullableIntArray.jet");
} }
public void testForIntRange() { public void testForIntRange() {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/forIntRange.jet"); blackBoxFile("controlStructures/forIntRange.jet");
} }
public void testKt237() throws Exception { public void testKt237() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt237.jet"); blackBoxFile("regressions/kt237.jet");
} }
public void testCompareToNull() throws Exception { public void testCompareToNull() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(a: String?, b: String?): Boolean = a == null && b !== null && null == a && null !== b"); loadText("fun foo(a: String?, b: String?): Boolean = a == null && b !== null && null == a && null !== b");
String text = generateToText(); String text = generateToText();
assertTrue(!text.contains("java/lang/Object.equals")); assertTrue(!text.contains("java/lang/Object.equals"));
@@ -202,6 +222,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testCompareToNonnullableEq() throws Exception { public void testCompareToNonnullableEq() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(a: String?, b: String): Boolean = a == b || b == a"); loadText("fun foo(a: String?, b: String): Boolean = a == b || b == a");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -210,6 +231,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testCompareToNonnullableNotEq() throws Exception { public void testCompareToNonnullableNotEq() throws Exception {
createEnvironmentWithMockJdk();
loadText("fun foo(a: String?, b: String): Boolean = a != b"); loadText("fun foo(a: String?, b: String): Boolean = a != b");
String text = generateToText(); String text = generateToText();
// System.out.println(text); // System.out.println(text);
@@ -220,15 +242,18 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testKt299() throws Exception { public void testKt299() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt299.jet"); blackBoxFile("regressions/kt299.jet");
} }
public void testKt416() throws Exception { public void testKt416() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt416.jet"); blackBoxFile("regressions/kt416.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt513() throws Exception { public void testKt513() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt513.jet"); blackBoxFile("regressions/kt513.jet");
} }
@@ -238,31 +263,37 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testKt769() throws Exception { public void testKt769() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt769.jet"); blackBoxFile("regressions/kt769.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt773() throws Exception { public void testKt773() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt773.jet"); blackBoxFile("regressions/kt773.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt772() throws Exception { public void testKt772() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt772.jet"); blackBoxFile("regressions/kt772.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt870() throws Exception { public void testKt870() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt870.jet"); blackBoxFile("regressions/kt870.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt958() throws Exception { public void testKt958() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt958.jet"); blackBoxFile("regressions/kt958.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testQuicksort() throws Exception { public void testQuicksort() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("controlStructures/quicksort.jet"); blackBoxFile("controlStructures/quicksort.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
@@ -280,18 +311,22 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testKt1076() throws Exception { public void testKt1076() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1076.kt"); blackBoxFile("regressions/kt1076.kt");
} }
public void testKt998() throws Exception { public void testKt998() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt998.kt"); blackBoxFile("regressions/kt998.kt");
} }
public void testKt628() throws Exception { public void testKt628() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt628.kt"); blackBoxFile("regressions/kt628.kt");
} }
public void testKt1441() throws Exception { public void testKt1441() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1441.kt"); blackBoxFile("regressions/kt1441.kt");
} }
} }
@@ -29,6 +29,7 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
} }
public void testSimple() throws Exception { public void testSimple() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
final Method foo = generateFunction("foo"); final Method foo = generateFunction("foo");
final Character c = (Character) foo.invoke(null); final Character c = (Character) foo.invoke(null);
@@ -36,6 +37,7 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
} }
public void testWhenFail() throws Exception { public void testWhenFail() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
// System.out.println(generateToText()); // System.out.println(generateToText());
Method foo = generateFunction("foo"); Method foo = generateFunction("foo");
@@ -43,15 +45,18 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
} }
public void testVirtual() throws Exception { public void testVirtual() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("extensionFunctions/virtual.jet"); blackBoxFile("extensionFunctions/virtual.jet");
} }
public void testShared() throws Exception { public void testShared() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("extensionFunctions/shared.kt"); blackBoxFile("extensionFunctions/shared.kt");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt475() throws Exception { public void testKt475() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt475.jet"); blackBoxFile("regressions/kt475.jet");
} }
@@ -23,6 +23,12 @@ import java.lang.reflect.Method;
* @author alex.tkachman * @author alex.tkachman
*/ */
public class FunctionGenTest extends CodegenTestCase { public class FunctionGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testDefaultArgs() throws Exception { public void testDefaultArgs() throws Exception {
blackBoxFile("functions/defaultargs.jet"); blackBoxFile("functions/defaultargs.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -30,6 +30,13 @@ import java.util.Arrays;
* @author yole * @author yole
*/ */
public class NamespaceGenTest extends CodegenTestCase { public class NamespaceGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testPSVM() throws Exception { public void testPSVM() throws Exception {
loadFile("PSVM.jet"); loadFile("PSVM.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -21,6 +21,12 @@ package org.jetbrains.jet.codegen;
* @author alex.tkachman * @author alex.tkachman
*/ */
public class ObjectGenTest extends CodegenTestCase { public class ObjectGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testSimpleObject() throws Exception { public void testSimpleObject() throws Exception {
blackBoxFile("objects/simpleObject.jet"); blackBoxFile("objects/simpleObject.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -24,6 +24,13 @@ import java.lang.reflect.Method;
* @author yole * @author yole
*/ */
public class PatternMatchingTest extends CodegenTestCase { public class PatternMatchingTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
@Override @Override
protected String getPrefix() { protected String getPrefix() {
return "patternMatching"; return "patternMatching";
@@ -23,6 +23,13 @@ import java.lang.reflect.Method;
* @author alex.tkachman * @author alex.tkachman
*/ */
public class PrimitiveTypesTest extends CodegenTestCase { public class PrimitiveTypesTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testPlus() throws Exception { public void testPlus() throws Exception {
loadText("fun f(a: Int, b: Int): Int { return a + b }"); loadText("fun f(a: Int, b: Int): Int { return a + b }");
@@ -31,6 +31,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testPrivateVal() throws Exception { public void testPrivateVal() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVal"); final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVal");
final Field[] fields = aClass.getDeclaredFields(); final Field[] fields = aClass.getDeclaredFields();
@@ -40,6 +41,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testPrivateVar() throws Exception { public void testPrivateVar() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVar"); final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVar");
final Object instance = aClass.newInstance(); final Object instance = aClass.newInstance();
@@ -50,6 +52,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testPublicVar() throws Exception { public void testPublicVar() throws Exception {
createEnvironmentWithMockJdk();
loadText("class PublicVar() { public var foo : Int = 0; }"); loadText("class PublicVar() { public var foo : Int = 0; }");
final Class aClass = loadImplementationClass(generateClassesInFile(), "PublicVar"); final Class aClass = loadImplementationClass(generateClassesInFile(), "PublicVar");
final Object instance = aClass.newInstance(); final Object instance = aClass.newInstance();
@@ -60,6 +63,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testAccessorsInInterface() { public void testAccessorsInInterface() {
createEnvironmentWithMockJdk();
loadText("class AccessorsInInterface() { public var foo : Int = 0; }"); loadText("class AccessorsInInterface() { public var foo : Int = 0; }");
final Class aClass = loadClass("AccessorsInInterface", generateClassesInFile()); final Class aClass = loadClass("AccessorsInInterface", generateClassesInFile());
assertNotNull(findMethodByName(aClass, "getFoo")); assertNotNull(findMethodByName(aClass, "getFoo"));
@@ -67,6 +71,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testPrivatePropertyInNamespace() throws Exception { public void testPrivatePropertyInNamespace() throws Exception {
createEnvironmentWithMockJdk();
loadText("private val x = 239"); loadText("private val x = 239");
final Class nsClass = generateNamespaceClass(); final Class nsClass = generateNamespaceClass();
final Field[] fields = nsClass.getDeclaredFields(); final Field[] fields = nsClass.getDeclaredFields();
@@ -79,6 +84,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testFieldPropertyAccess() throws Exception { public void testFieldPropertyAccess() throws Exception {
createEnvironmentWithMockJdk();
loadFile("properties/fieldPropertyAccess.jet"); loadFile("properties/fieldPropertyAccess.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method method = generateFunction(); final Method method = generateFunction();
@@ -87,12 +93,14 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testFieldGetter() throws Exception { public void testFieldGetter() throws Exception {
createEnvironmentWithMockJdk();
loadText("val now: Long get() = System.currentTimeMillis(); fun foo() = now"); loadText("val now: Long get() = System.currentTimeMillis(); fun foo() = now");
final Method method = generateFunction("foo"); final Method method = generateFunction("foo");
assertIsCurrentTime((Long) method.invoke(null)); assertIsCurrentTime((Long) method.invoke(null));
} }
public void testFieldSetter() throws Exception { public void testFieldSetter() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
final Method method = generateFunction("append"); final Method method = generateFunction("append");
method.invoke(null, "IntelliJ "); method.invoke(null, "IntelliJ ");
@@ -104,6 +112,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testFieldSetterPlusEq() throws Exception { public void testFieldSetterPlusEq() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
final Method method = generateFunction("append"); final Method method = generateFunction("append");
method.invoke(null, "IntelliJ "); method.invoke(null, "IntelliJ ");
@@ -112,6 +121,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testAccessorsWithoutBody() throws Exception { public void testAccessorsWithoutBody() throws Exception {
createEnvironmentWithMockJdk();
loadText("class AccessorsWithoutBody() { protected var foo: Int = 349\n get\n private set\n fun setter() { foo = 610; } } "); loadText("class AccessorsWithoutBody() { protected var foo: Int = 349\n get\n private set\n fun setter() { foo = 610; } } ");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Class aClass = loadImplementationClass(generateClassesInFile(), "AccessorsWithoutBody"); final Class aClass = loadImplementationClass(generateClassesInFile(), "AccessorsWithoutBody");
@@ -129,6 +139,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testInitializersForNamespaceProperties() throws Exception { public void testInitializersForNamespaceProperties() throws Exception {
createEnvironmentWithMockJdk();
loadText("val x = System.currentTimeMillis()"); loadText("val x = System.currentTimeMillis()");
final Method method = generateFunction("getX"); final Method method = generateFunction("getX");
method.setAccessible(true); method.setAccessible(true);
@@ -136,6 +147,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testPropertyReceiverOnStack() throws Exception { public void testPropertyReceiverOnStack() throws Exception {
createEnvironmentWithMockJdk();
loadFile(); loadFile();
final Class aClass = loadImplementationClass(generateClassesInFile(), "Evaluator"); final Class aClass = loadImplementationClass(generateClassesInFile(), "Evaluator");
final Constructor constructor = aClass.getConstructor(StringBuilder.class); final Constructor constructor = aClass.getConstructor(StringBuilder.class);
@@ -147,6 +159,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testAbstractVal() throws Exception { public void testAbstractVal() throws Exception {
createEnvironmentWithMockJdk();
loadText("abstract class Foo { public abstract val x: String }"); loadText("abstract class Foo { public abstract val x: String }");
final ClassFileFactory codegens = generateClassesInFile(); final ClassFileFactory codegens = generateClassesInFile();
final Class aClass = loadClass("Foo", codegens); final Class aClass = loadClass("Foo", codegens);
@@ -154,6 +167,7 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testVolatileProperty() throws Exception { public void testVolatileProperty() throws Exception {
createEnvironmentWithMockJdk();
loadText("abstract class Foo { public volatile var x: String = \"\"; }"); loadText("abstract class Foo { public volatile var x: String = \"\"; }");
// System.out.println(generateToText()); // System.out.println(generateToText());
final ClassFileFactory codegens = generateClassesInFile(); final ClassFileFactory codegens = generateClassesInFile();
@@ -163,15 +177,18 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testKt257 () throws Exception { public void testKt257 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt257.jet"); blackBoxFile("regressions/kt257.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
public void testKt613 () throws Exception { public void testKt613 () throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt613.jet"); blackBoxFile("regressions/kt613.jet");
} }
public void testKt160() throws Exception { public void testKt160() throws Exception {
createEnvironmentWithMockJdk();
loadText("internal val s = java.lang.Double.toString(1.0)"); loadText("internal val s = java.lang.Double.toString(1.0)");
final Method method = generateFunction("getS"); final Method method = generateFunction("getS");
method.setAccessible(true); method.setAccessible(true);
@@ -179,10 +196,12 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testKt1165() throws Exception { public void testKt1165() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1165.kt"); blackBoxFile("regressions/kt1165.kt");
} }
public void testKt1168() throws Exception { public void testKt1168() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1168.kt"); blackBoxFile("regressions/kt1168.kt");
} }
@@ -192,14 +211,17 @@ public class PropertyGenTest extends CodegenTestCase {
} }
public void testKt1159() throws Exception { public void testKt1159() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1159.kt"); blackBoxFile("regressions/kt1159.kt");
} }
public void testKt1417() throws Exception { public void testKt1417() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1417.kt"); blackBoxFile("regressions/kt1417.kt");
} }
public void testKt1398() throws Exception { public void testKt1398() throws Exception {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt1398.kt"); blackBoxFile("regressions/kt1398.kt");
} }
@@ -17,6 +17,12 @@
package org.jetbrains.jet.codegen; package org.jetbrains.jet.codegen;
public class SafeRefTest extends CodegenTestCase { public class SafeRefTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void test247 () throws Exception { public void test247 () throws Exception {
blackBoxFile("regressions/kt247.jet"); blackBoxFile("regressions/kt247.jet");
} }
@@ -25,6 +25,12 @@ import java.lang.reflect.Method;
*/ */
public class StringsTest extends CodegenTestCase { public class StringsTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testAnyToString () throws InvocationTargetException, IllegalAccessException { public void testAnyToString () throws InvocationTargetException, IllegalAccessException {
loadText("fun foo(x: Any) = x.toString()"); loadText("fun foo(x: Any) = x.toString()");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -17,6 +17,13 @@
package org.jetbrains.jet.codegen; package org.jetbrains.jet.codegen;
public class SuperGenTest extends CodegenTestCase { public class SuperGenTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testBasicProperty () { public void testBasicProperty () {
blackBoxFile("/super/basicproperty.jet"); blackBoxFile("/super/basicproperty.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -17,6 +17,13 @@
package org.jetbrains.jet.codegen; package org.jetbrains.jet.codegen;
public class TraitsTest extends CodegenTestCase { public class TraitsTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
@Override @Override
protected String getPrefix() { protected String getPrefix() {
return "traits"; return "traits";
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen;
public class TupleGenTest extends CodegenTestCase { public class TupleGenTest extends CodegenTestCase {
public void testBasic() { public void testBasic() {
createEnvironmentWithMockJdk();
blackBoxFile("/tuples/basic.jet"); blackBoxFile("/tuples/basic.jet");
// System.out.println(generateToText()); // System.out.println(generateToText());
} }
@@ -16,8 +16,6 @@
package org.jetbrains.jet.codegen; package org.jetbrains.jet.codegen;
import jet.TypeCastException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
/** /**
@@ -25,6 +23,13 @@ import java.lang.reflect.Method;
* @author alex.tkachman * @author alex.tkachman
*/ */
public class TypeInfoTest extends CodegenTestCase { public class TypeInfoTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
@Override @Override
protected String getPrefix() { protected String getPrefix() {
return "typeInfo"; return "typeInfo";
@@ -19,13 +19,13 @@ package org.jetbrains.jet.codegen;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays;
/** /**
* @author alex.tkachman * @author alex.tkachman
*/ */
public class VarArgTest extends CodegenTestCase { public class VarArgTest extends CodegenTestCase {
public void testStringArray () throws InvocationTargetException, IllegalAccessException { public void testStringArray () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test(vararg ts: String) = ts"); loadText("fun test(vararg ts: String) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -34,6 +34,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testIntArray () throws InvocationTargetException, IllegalAccessException { public void testIntArray () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test(vararg ts: Int) = ts"); loadText("fun test(vararg ts: Int) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
@@ -42,6 +43,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testIntArrayKotlinNoArgs () throws InvocationTargetException, IllegalAccessException { public void testIntArrayKotlinNoArgs () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test() = testf(); fun testf(vararg ts: Int) = ts"); loadText("fun test() = testf(); fun testf(vararg ts: Int) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -50,6 +52,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { public void testIntArrayKotlin () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test() = testf(239, 7); fun testf(vararg ts: Int) = ts"); loadText("fun test() = testf(239, 7); fun testf(vararg ts: Int) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -60,6 +63,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test() = testf(239.toByte(), 7.toByte()); fun testf(vararg ts: Byte?) = ts"); loadText("fun test() = testf(239.toByte(), 7.toByte()); fun testf(vararg ts: Byte?) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -70,6 +74,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testIntArrayKotlinObj () throws InvocationTargetException, IllegalAccessException { public void testIntArrayKotlinObj () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test() = testf(\"239\"); fun testf(vararg ts: String) = ts"); loadText("fun test() = testf(\"239\"); fun testf(vararg ts: String) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -79,6 +84,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testArrayT () throws InvocationTargetException, IllegalAccessException { public void testArrayT () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("fun test() = _array(2, 4); fun <T> _array(vararg elements : T) = elements"); loadText("fun test() = _array(2, 4); fun <T> _array(vararg elements : T) = elements");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -94,10 +100,12 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testKt797() { public void testKt797() {
createEnvironmentWithMockJdk();
blackBoxFile("regressions/kt796_797.jet"); blackBoxFile("regressions/kt796_797.jet");
} }
public void testArrayAsVararg () throws InvocationTargetException, IllegalAccessException { public void testArrayAsVararg () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("private fun asList(vararg elems: String) = elems; fun test(ts: Array<String>) = asList(*ts); "); loadText("private fun asList(vararg elems: String) = elems; fun test(ts: Array<String>) = asList(*ts); ");
//System.out.println(generateToText()); //System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -106,6 +114,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testArrayAsVararg2 () throws InvocationTargetException, IllegalAccessException { public void testArrayAsVararg2 () throws InvocationTargetException, IllegalAccessException {
createEnvironmentWithMockJdk();
loadText("private fun asList(vararg elems: String) = elems; fun test(ts1: Array<String>, ts2: String) = asList(*ts1, ts2); "); loadText("private fun asList(vararg elems: String) = elems; fun test(ts1: Array<String>, ts2: String) = asList(*ts1, ts2); ");
System.out.println(generateToText()); System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
@@ -41,6 +41,14 @@ import java.util.List;
* @since 4/6/12 * @since 4/6/12
*/ */
public class DescriptorRendererTest extends JetLiteFixture { public class DescriptorRendererTest extends JetLiteFixture {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testGlobalProperties() throws IOException { public void testGlobalProperties() throws IOException {
doTest(); doTest();
} }
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.CompileCompilerDependenciesTest; import org.jetbrains.jet.CompileCompilerDependenciesTest;
import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Diagnostic;
@@ -32,6 +32,9 @@ public abstract class ExtensibleResolveTestCase extends JetLiteFixture {
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
createEnvironmentWithMockJdk();
expectedResolveData = getExpectedResolveData(); expectedResolveData = getExpectedResolveData();
} }
@@ -22,6 +22,14 @@ import org.jetbrains.jet.codegen.CodegenTestCase;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class JetNpeTest extends CodegenTestCase { public class JetNpeTest extends CodegenTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdk();
}
public void testStackTrace () { public void testStackTrace () {
try { try {
Intrinsics.throwNpe(); Intrinsics.throwNpe();
@@ -45,6 +45,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
super.createEnvironmentWithMockJdk();
tc.setUp(); tc.setUp();
} }
@@ -40,6 +40,7 @@ public class JetOverloadTest extends JetLiteFixture {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
createEnvironmentWithMockJdk();
InjectorForTests injector = new InjectorForTests(getProject()); InjectorForTests injector = new InjectorForTests(getProject());
library = injector.getJetStandardLibrary(); library = injector.getJetStandardLibrary();
descriptorResolver = injector.getDescriptorResolver(); descriptorResolver = injector.getDescriptorResolver();
@@ -40,6 +40,7 @@ public class JetOverridingTest extends JetLiteFixture {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
createEnvironmentWithMockJdk();
InjectorForTests injector = new InjectorForTests(getProject()); InjectorForTests injector = new InjectorForTests(getProject());
library = injector.getJetStandardLibrary(); library = injector.getJetStandardLibrary();
descriptorResolver = injector.getDescriptorResolver(); descriptorResolver = injector.getDescriptorResolver();
@@ -66,6 +66,9 @@ public class JetTypeCheckerTest extends JetLiteFixture {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
super.createEnvironmentWithMockJdk();
library = JetStandardLibrary.getInstance(); library = JetStandardLibrary.getInstance();
classDefinitions = new ClassDefinitions(); classDefinitions = new ClassDefinitions();