Add JetDiagnosticTest with stdlib
This commit is contained in:
-3
@@ -9,6 +9,3 @@ class Test2
|
||||
val c: Class<*> = javaClass<A>()
|
||||
|
||||
class A
|
||||
|
||||
// from stdlib
|
||||
fun <T> javaClass() : Class<T> = null <!CAST_NEVER_SUCCEEDS!>as<!> Class<T>
|
||||
-4
@@ -30,7 +30,3 @@ val ia: IntArray = intArray(1, 2)
|
||||
val sa: Array<String> = array("a", "b")
|
||||
|
||||
annotation class Ann2
|
||||
|
||||
// from stdlib
|
||||
fun <T> array(vararg t : T) : Array<T> = t
|
||||
fun intArray(vararg content : Int) : IntArray = content
|
||||
@@ -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)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
@@ -101,6 +102,10 @@ fun main(args: Array<String>) {
|
||||
model("codegen/box/functions/tailRecursion")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractJetDiagnosticsTestWithStdLib>()) {
|
||||
model("diagnostics/testsWithStdLib")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractResolveTest>()) {
|
||||
model("resolve", extension = "resolve")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user