merge FullJetPsiCheckerTest into QuickJetPsiCheckerTest

This commit is contained in:
Stepan Koltsov
2011-11-25 18:22:40 +04:00
parent 778e8fd21b
commit 7bc2736568
100 changed files with 92 additions and 141 deletions
@@ -1,4 +0,0 @@
import java.util.Collections
import java.util.List
val ab = Collections.emptyList<Int>() : List<Int>?
@@ -1,3 +1,5 @@
// +JDK
namespace abstract namespace abstract
class MyClass() { class MyClass() {
@@ -1,3 +1,5 @@
// +JDK
import java.util.* import java.util.*
namespace html { namespace html {
@@ -1,3 +1,5 @@
// +JDK
namespace Jet86 namespace Jet86
class A { class A {
@@ -1,3 +1,5 @@
// +JDK
trait A { trait A {
fun foo() : Int = 1 fun foo() : Int = 1
fun foo2() : Int = 1 fun foo2() : Int = 1
@@ -1,3 +1,5 @@
// +JDK
fun Int?.optint() : Unit {} fun Int?.optint() : Unit {}
val Int?.optval : Unit = () val Int?.optval : Unit = ()
@@ -1,3 +1,5 @@
// +JDK
import java.util.*; import java.util.*;
class NotRange1() { class NotRange1() {
@@ -1,3 +1,5 @@
// +JDK
fun none() {} fun none() {}
fun unitEmptyInfer() {} fun unitEmptyInfer() {}
@@ -1,3 +1,5 @@
// +JDK
namespace foobar namespace foobar
namespace a { namespace a {
@@ -1,3 +1,5 @@
// +JDK
fun test() { fun test() {
val a : Int? = 0 val a : Int? = 0
if (a != null) { if (a != null) {
@@ -1,3 +1,5 @@
// +JDK
// Fixpoint generic in Java: Enum<T extends Enum<T>> // Fixpoint generic in Java: Enum<T extends Enum<T>>
fun test(a : annotation.RetentionPolicy) { fun test(a : annotation.RetentionPolicy) {
@@ -1,3 +1,5 @@
// +JDK
import java.* import java.*
import util.* import util.*
import <!UNRESOLVED_REFERENCE!>utils<!>.* import <!UNRESOLVED_REFERENCE!>utils<!>.*
@@ -1,3 +1,5 @@
// +JDK
fun t1() : Int{ fun t1() : Int{
return 0 return 0
<!UNREACHABLE_CODE!>1<!> <!UNREACHABLE_CODE!>1<!>
@@ -1,3 +1,5 @@
// +JDK
class Foo1() : java.util.ArrayList<Int>() class Foo1() : java.util.ArrayList<Int>()
open class Bar() { open class Bar() {
@@ -1,4 +1,5 @@
// KT-389 Wrong type inference for varargs etc. // KT-389 Wrong type inference for varargs etc.
// +JDK
import java.util.* import java.util.*
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
import java.util.Collection; import java.util.Collection;
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
import java.util.Collection; import java.util.Collection;
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
fun ff(l: Any) = l as List<*> fun ff(l: Any) = l as List<*>
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
fun ff(a: Any) = <!UNCHECKED_CAST!>a as List<String><!> fun ff(a: Any) = <!UNCHECKED_CAST!>a as List<String><!>
@@ -1,3 +1,5 @@
// +JDK
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -1,3 +1,5 @@
// +JDK
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
fun ff(l: Any) = l is <!CANNOT_CHECK_FOR_ERASED!>List<String><!> fun ff(l: Any) = l is <!CANNOT_CHECK_FOR_ERASED!>List<String><!>
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
fun ff(l: Any) = l is List<*> fun ff(l: Any) = l is List<*>
@@ -1,3 +1,5 @@
// +JDK
import java.util.List; import java.util.List;
fun ff(l: Any) = when(l) { fun ff(l: Any) = when(l) {
@@ -1,4 +1,5 @@
//KT-600 Problem with 'sure' extension function type inference //KT-600 Problem with 'sure' extension function type inference
// +JDK
fun <T : Any> T?.sure() : T { if (this != null) return this else throw NullPointerException() } fun <T : Any> T?.sure() : T { if (this != null) return this else throw NullPointerException() }
@@ -1,3 +1,5 @@
// +JDK
import java.* import java.*
import util.* import util.*
@@ -0,0 +1,6 @@
// +JDK
import java.util.Collections
import java.util.List
val ab = Collections.emptyList<Int>() : List<Int>?
@@ -1,4 +1,5 @@
// JET-72 Type inference doesn't work when iterating over ArrayList // JET-72 Type inference doesn't work when iterating over ArrayList
// +JDK
import java.util.ArrayList import java.util.ArrayList
@@ -1,4 +1,5 @@
// KT-258 Support equality constraints in type inference // KT-258 Support equality constraints in type inference
// +JDK
import java.util.* import java.util.*
@@ -1,4 +1,6 @@
// KT-287 Infer constructor type arguments // KT-287 Infer constructor type arguments
// +JDK
import java.util.* import java.util.*
fun attributes() : Map<String, String> = HashMap() // Should be inferred; fun attributes() : Map<String, String> = HashMap() // Should be inferred;
@@ -1,4 +1,5 @@
// KT-313 Bug in substitutions in a function returning its type parameter T // KT-313 Bug in substitutions in a function returning its type parameter T
// +JDK
fun <T> Iterable<T>.join(separator : String?) : String { fun <T> Iterable<T>.join(separator : String?) : String {
return separator.npe() return separator.npe()
@@ -1,5 +1,6 @@
// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference) // KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference)
// KT-335 Type inference fails on Collections.sort // KT-335 Type inference fails on Collections.sort
// +JDK
import java.util.* import java.util.*
import java.lang.Comparable as Comparable import java.lang.Comparable as Comparable
@@ -1,6 +1,7 @@
// KT-385 type inference does not work properly` // KT-385 type inference does not work properly`
// KT-109 Good code is red: type arguments are not inferred // KT-109 Good code is red: type arguments are not inferred
// KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible // KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible
// +JDK
import java.util.* import java.util.*
@@ -1,4 +1,5 @@
// KT-459 Type argument inference fails when class names are fully qualified // KT-459 Type argument inference fails when class names are fully qualified
// +JDK
fun test() { fun test() {
val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure! val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure!
@@ -1,3 +1,5 @@
// +JDK
namespace kt469 namespace kt469
//KT-512 plusAssign() : Unit does not work properly //KT-512 plusAssign() : Unit does not work properly
@@ -1,4 +1,6 @@
//KT-549 type inference failed //KT-549 type inference failed
// +JDK
namespace demo namespace demo
fun filter<T>(list : Array<T>, filter : fun (T) : Boolean) : java.util.List<T> { fun filter<T>(list : Array<T>, filter : fun (T) : Boolean) : java.util.List<T> {
@@ -1,4 +1,5 @@
//KT-58 Allow finally around definite returns //KT-58 Allow finally around definite returns
// +JDK
namespace kt58 namespace kt58
@@ -1,4 +1,6 @@
//KT-580 Type inference failed //KT-580 Type inference failed
// +JDK
namespace whats.the.difference namespace whats.the.difference
import java.util.* import java.util.*
@@ -1,4 +1,6 @@
// KT-588 Unresolved static method // KT-588 Unresolved static method
// +JDK
class Test() : Thread("Test") { class Test() : Thread("Test") {
class object { class object {
fun init2() { fun init2() {
@@ -1,4 +1,5 @@
//KT-235 Illegal assignment return type //KT-235 Illegal assignment return type
// +JDK
namespace kt235 namespace kt235
@@ -1,119 +0,0 @@
package org.jetbrains.jet.checkers;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.TextRange;
import junit.framework.Test;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetLiteFixture;
import org.jetbrains.jet.JetTestCaseBuilder;
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.ImportingStrategy;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports;
import java.util.List;
/**
* @author abreslav
*/
public class FullJetPsiCheckerTest extends JetLiteFixture {
private final String myDataPath;
private String myName;
public FullJetPsiCheckerTest(@NonNls String dataPath, String name) {
myDataPath = dataPath;
myName = name;
}
@Override
public String getName() {
return "test" + myName;
}
@Override
public void runTest() throws Exception {
String fileName = myName + ".jet";
String fullPath = myDataPath + "/" + fileName;
String expectedText = loadFile(fullPath);
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
myFile = createPsiFile(myName, clearText);
boolean importJdk = !expectedText.contains("-JDK");
ImportingStrategy importingStrategy = importJdk ? JavaDefaultImports.JAVA_DEFAULT_IMPORTS : ImportingStrategy.NONE;
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(importingStrategy), myFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
@Override
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
String message = "Missing " + type + DiagnosticUtils.atLocation(myFile, new TextRange(expectedStart, expectedEnd));
System.err.println(message);
}
@Override
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
String message = "Unexpected " + type + DiagnosticUtils.atLocation(myFile, new TextRange(actualStart, actualEnd));
System.err.println(message);
}
});
String actualText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
assertEquals(expectedText, actualText);
// String myFullDataPath = getTestDataPath() + getDataPath();
// System.out.println("myFullDataPath = " + myFullDataPath);
// convert(new File(myFullDataPath + "/../../checker/"), new File(myFullDataPath));
}
/*
private void convert(File src, File dest) throws IOException {
File[] files = src.listFiles();
for (File file : files) {
try {
if (file.isDirectory()) {
File destDir = new File(dest, file.getName());
destDir.mkdir();
convert(file, destDir);
continue;
}
if (!file.getName().endsWith(".jet")) continue;
String text = loadFile(file.getAbsolutePath());
Pattern pattern = Pattern.compile("</?(error|warning|info( descr=\"[\\w ]+\")?)>");
String clearText = pattern.matcher(text).replaceAll("");
configureFromFileText(file.getName(), clearText);
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache((JetFile) myFile);
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
File destFile = new File(dest, file.getName());
FileWriter fileWriter = new FileWriter(destFile);
fileWriter.write(expectedText);
fileWriter.close();
}
catch (RuntimeException e) {
e.printStackTrace();
}
}
}
*/
public static Test suite() {
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public Test createTest(@NotNull String dataPath, @NotNull String name) {
return new FullJetPsiCheckerTest(dataPath, name);
}
});
}
}