diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/array.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt similarity index 100% rename from compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/array.kt rename to compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/classLiteral.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/classLiteral.kt similarity index 66% rename from compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/classLiteral.kt rename to compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/classLiteral.kt index 1c043cd0a2e..6f5610ee40c 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/classLiteral.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/classLiteral.kt @@ -9,6 +9,3 @@ class Test2 val c: Class<*> = javaClass() class A - -// from stdlib -fun javaClass() : Class = null as Class diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/simple.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt similarity index 86% rename from compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/simple.kt rename to compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt index ec35fcd1b5b..67eeb9fb992 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/simple.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt @@ -30,7 +30,3 @@ val ia: IntArray = intArray(1, 2) val sa: Array = array("a", "b") annotation class Ann2 - -// from stdlib -fun array(vararg t : T) : Array = t -fun intArray(vararg content : Int) : IntArray = content diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/vararg.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt similarity index 100% rename from compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/vararg.kt rename to compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt diff --git a/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTestWithStdLib.java b/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTestWithStdLib.java new file mode 100644 index 00000000000..413227be3de --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTestWithStdLib.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2014 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.checkers; + +import org.jetbrains.jet.ConfigurationKind; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.TestJdkKind; +import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; + +import java.io.File; +import java.util.Arrays; + +public abstract class AbstractJetDiagnosticsTestWithStdLib extends AbstractJetDiagnosticsTest { + @Override + protected JetCoreEnvironment createEnvironment() { + File javaFilesDir = createJavaFilesDir(); + return JetCoreEnvironment.createForTests(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( + ConfigurationKind.ALL, + TestJdkKind.MOCK_JDK, + Arrays.asList(JetTestUtils.getAnnotationsJar()), + Arrays.asList(javaFilesDir) + )); + } +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/BaseDiagnosticsTest.java b/compiler/tests/org/jetbrains/jet/checkers/BaseDiagnosticsTest.java index 6cfd0b1670b..7919b1dc5a1 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/BaseDiagnosticsTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/BaseDiagnosticsTest.java @@ -70,6 +70,16 @@ public abstract class BaseDiagnosticsTest extends JetLiteFixture { @Override protected JetCoreEnvironment createEnvironment() { + File javaFilesDir = createJavaFilesDir(); + return JetCoreEnvironment.createForTests(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( + ConfigurationKind.JDK_AND_ANNOTATIONS, + TestJdkKind.MOCK_JDK, + Arrays.asList(JetTestUtils.getAnnotationsJar()), + Arrays.asList(javaFilesDir) + )); + } + + protected File createJavaFilesDir() { File javaFilesDir = new File(FileUtil.getTempDirectory(), "java-files"); try { JetTestUtils.mkdirs(javaFilesDir); @@ -77,12 +87,7 @@ public abstract class BaseDiagnosticsTest extends JetLiteFixture { catch (IOException e) { throw ExceptionUtils.rethrow(e); } - return JetCoreEnvironment.createForTests(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( - ConfigurationKind.JDK_AND_ANNOTATIONS, - TestJdkKind.MOCK_JDK, - Arrays.asList(JetTestUtils.getAnnotationsJar()), - Arrays.asList(javaFilesDir) - )); + return javaFilesDir; } private static boolean writeJavaFile(@NotNull String fileName, @NotNull String content, @NotNull File javaFilesDir) { diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index d36532cdb1f..8263b00158d 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -637,21 +637,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("array.kt") - public void testArray() throws Exception { - doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/array.kt"); - } - @TestMetadata("booleanLocalVal.kt") public void testBooleanLocalVal() throws Exception { doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.kt"); } - @TestMetadata("classLiteral.kt") - public void testClassLiteral() throws Exception { - doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/classLiteral.kt"); - } - @TestMetadata("compareAndEquals.kt") public void testCompareAndEquals() throws Exception { doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.kt"); @@ -672,21 +662,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt"); } - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/simple.kt"); - } - @TestMetadata("strings.kt") public void testStrings() throws Exception { doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.kt"); } - @TestMetadata("vararg.kt") - public void testVararg() throws Exception { - doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/vararg.kt"); - } - } public static Test innerSuite() { diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java new file mode 100644 index 00000000000..89a318e34e0 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -0,0 +1,89 @@ +/* + * 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.checkers; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTestWithStdLib; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/diagnostics/testsWithStdLib") +@InnerTestClasses({JetDiagnosticsTestWithStdLibGenerated.Annotations.class}) +public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInTestsWithStdLib() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") + @InnerTestClasses({Annotations.AnnotationParameterMustBeConstant.class}) + public static class Annotations extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInAnnotations() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib/annotations"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant") + public static class AnnotationParameterMustBeConstant extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInAnnotationParameterMustBeConstant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("array.kt") + public void testArray() throws Exception { + doTest("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt"); + } + + @TestMetadata("classLiteral.kt") + public void testClassLiteral() throws Exception { + doTest("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/classLiteral.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + doTest("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt"); + } + + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + doTest("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt"); + } + + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Annotations"); + suite.addTestSuite(Annotations.class); + suite.addTestSuite(AnnotationParameterMustBeConstant.class); + return suite; + } + } + + public static Test suite() { + TestSuite suite = new TestSuite("JetDiagnosticsTestWithStdLibGenerated"); + suite.addTestSuite(JetDiagnosticsTestWithStdLibGenerated.class); + suite.addTest(Annotations.innerSuite()); + return suite; + } +} diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 4954c30139a..ad8df2c6c9c 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -89,6 +89,7 @@ import org.jetbrains.jet.resolve.AbstractReferenceResolveInLibrarySourcesTest import org.jetbrains.jet.completion.AbstractCompiledKotlinInJavaCompletionTest import org.jetbrains.jet.completion.AbstractKotlinSourceInJavaCompletionTest import org.jetbrains.jet.plugin.intentions.AbstractIntentionTest +import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTestWithStdLib fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -101,6 +102,10 @@ fun main(args: Array) { model("codegen/box/functions/tailRecursion") } + testClass(javaClass()) { + model("diagnostics/testsWithStdLib") + } + testClass(javaClass()) { model("resolve", extension = "resolve") }