diff --git a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/CodegenTestsOnAndroidGenerator.java b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/CodegenTestsOnAndroidGenerator.java index fcce2b2a332..7e1d3e47257 100644 --- a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/CodegenTestsOnAndroidGenerator.java +++ b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/CodegenTestsOnAndroidGenerator.java @@ -52,8 +52,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase { private JetCoreEnvironment environmentWithMockJdk = JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS); private JetCoreEnvironment environmentWithFullJdk = JetTestUtils.createEnvironmentWithFullJdk(myTestRootDisposable); - private JetCoreEnvironment environmentWithFullJdkAndJUnit; - + private final Pattern packagePattern = Pattern.compile("package (.*)"); private final List generatedTestNames = Lists.newArrayList(); @@ -64,16 +63,6 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase { private CodegenTestsOnAndroidGenerator(PathManager pathManager) { this.pathManager = pathManager; - - File junitJar = new File("libraries/lib/junit-4.9.jar"); - - if (!junitJar.exists()) { - throw new AssertionError(); - } - - environmentWithFullJdkAndJUnit = new JetCoreEnvironment(myTestRootDisposable, JetTestUtils.compilerConfigurationForTests( - ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar(), junitJar)); - } private void generateOutputFiles() throws Throwable { @@ -130,7 +119,6 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase { Assert.assertNotNull("Folder with testData is empty: " + dir.getAbsolutePath(), files); Set excludedFiles = SpecialFiles.getExcludedFiles(); Set filesCompiledWithoutStdLib = SpecialFiles.getFilesCompiledWithoutStdLib(); - Set filesCompiledWithJUnit = SpecialFiles.getFilesCompiledWithJUnit(); for (File file : files) { if (excludedFiles.contains(file.getName())) { continue; @@ -149,9 +137,6 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase { if (filesCompiledWithoutStdLib.contains(file.getName())) { factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithMockJdk); } - else if (filesCompiledWithJUnit.contains(file.getName())) { - factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithFullJdkAndJUnit); - } else { factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithFullJdk); } diff --git a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java index ff0ba446776..0f8162e20ec 100644 --- a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java +++ b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java @@ -24,19 +24,13 @@ import java.util.Set; public class SpecialFiles { private static final Set excludedFiles = Sets.newHashSet(); private static final Set filesCompiledWithoutStdLib = Sets.newHashSet(); - private static final Set filesCompiledWithJUnit = Sets.newHashSet(); static { fillExcludedFiles(); fillFilesCompiledWithoutStdLib(); - fillFilesCompiledWithJUnit(); } - public static Set getFilesCompiledWithJUnit() { - return filesCompiledWithJUnit; - } - public static Set getExcludedFiles() { return excludedFiles; } @@ -45,10 +39,6 @@ public class SpecialFiles { return filesCompiledWithoutStdLib; } - private static void fillFilesCompiledWithJUnit() { - filesCompiledWithJUnit.add("kt2334.kt"); - } - private static void fillFilesCompiledWithoutStdLib() { filesCompiledWithoutStdLib.add("kt1980.kt"); filesCompiledWithoutStdLib.add("kt1953_class.kt"); // Exception in code diff --git a/compiler/testData/codegen/regressions/kt1592.kt b/compiler/testData/codegen/junit/kt1592.kt similarity index 100% rename from compiler/testData/codegen/regressions/kt1592.kt rename to compiler/testData/codegen/junit/kt1592.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt2334.kt b/compiler/testData/codegen/junit/kt2344.kt similarity index 74% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt2334.kt rename to compiler/testData/codegen/junit/kt2344.kt index f51b1913b75..4c3088991aa 100644 --- a/compiler/testData/codegen/boxWithStdlib/regressions/kt2334.kt +++ b/compiler/testData/codegen/junit/kt2344.kt @@ -7,7 +7,6 @@ public class Test { } } -fun box() : String { - Test().f() - return "OK" +fun foo() { + Test().f() } diff --git a/compiler/tests/org/jetbrains/jet/codegen/JUnitUsageGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/JUnitUsageGenTest.java new file mode 100644 index 00000000000..ea8d756f496 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/codegen/JUnitUsageGenTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.codegen; + +import org.jetbrains.jet.ConfigurationKind; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.TestJdkKind; +import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; +import org.junit.Test; + +import java.io.File; +import java.lang.reflect.Method; + +public class JUnitUsageGenTest extends CodegenTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + File junitJar = new File("libraries/lib/junit-4.9.jar"); + + if (!junitJar.exists()) { + throw new AssertionError("JUnit jar wasn't found"); + } + + myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( + ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, junitJar)); + } + + public void testKt2344() throws Exception { + loadFile("junit/kt2344.kt"); + generateFunction().invoke(null); + } + + public void testKt1592() throws Exception { + loadFile("junit/kt1592.kt"); + Class namespaceClass = generateNamespaceClass(); + Method method = namespaceClass.getMethod("foo", Method.class); + method.setAccessible(true); + Test annotation = method.getAnnotation(Test.class); + assertEquals(annotation.timeout(), 0l); + assertEquals(annotation.expected(), Test.None.class); + } +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java index 0800d633179..7c87ecb378a 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java @@ -16,68 +16,27 @@ package org.jetbrains.jet.codegen; -import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.ConfigurationKind; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.TestJdkKind; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; -import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime; -import org.jetbrains.jet.lang.psi.JetPsiUtil; -import org.junit.Test; -import java.io.File; import java.lang.annotation.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; public class StdlibTest extends CodegenTestCase { @Override protected void setUp() throws Exception { super.setUp(); - File junitJar = new File("libraries/lib/junit-4.9.jar"); - - if (!junitJar.exists()) { - throw new AssertionError(); - } if (myEnvironment != null) { throw new IllegalStateException("must not set up myEnvironemnt twice"); } myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( - ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar(), junitJar)); + ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar())); } - @NotNull - @Override - protected GeneratedClassLoader createClassLoader(@NotNull ClassFileFactory codegens) { - try { - return new GeneratedClassLoader( - codegens, - new URLClassLoader(new URL[]{ForTestCompileRuntime.runtimeJarForTests().toURI().toURL()}, - getClass().getClassLoader())); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - - //from NamespaceGenTest -// public void testPredicateOperator() throws Exception { -// loadText("fun foo(s: String) = s?startsWith(\"J\")"); -// final Method main = generateFunction(); -// try { -// assertEquals("JetBrains", main.invoke(null, "JetBrains")); -// assertNull(main.invoke(null, "IntelliJ")); -// } catch (Throwable t) { -//// System.out.println(generateToText()); -// t.printStackTrace(); -// throw t instanceof Exception ? (Exception)t : new RuntimeException(t); -// } -// } -// public void testForInString() throws Exception { loadText("fun foo() : Int { var sum = 0\n" + " for(c in \"239\")\n" + @@ -94,17 +53,6 @@ public class StdlibTest extends CodegenTestCase { } } - public void testKt1592 () throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - loadFile("regressions/kt1592.kt"); - String fqName = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(myFiles.getPsiFile())).getFqName().getFqName(); - Class namespaceClass = generateClass(fqName); - Method method = namespaceClass.getMethod("foo", Method.class); - method.setAccessible(true); - Test annotation = method.getAnnotation(Test.class); - assertEquals(annotation.timeout(), 0l); - assertEquals(annotation.expected(), Test.None.class); - } - public void testAnnotationClassWithClassProperty() throws NoSuchFieldException,