Tests for diagnostics on this and super are moved and broken into smaller parts

This commit is contained in:
Andrey Breslav
2012-11-01 19:29:06 +04:00
parent a0cd26960a
commit 20906e34ce
11 changed files with 126 additions and 79 deletions
@@ -1,42 +0,0 @@
// FILE: f.kt
class Dup {
fun Dup() : Unit {
this<!AMBIGUOUS_LABEL!>@Dup<!>
}
}
class A() {
fun foo() : Unit {
this@A
this<!UNRESOLVED_REFERENCE!>@a<!>
this
}
val x = this@A.foo()
val y = this.foo()
val z = foo()
}
fun foo1() : Unit {
<!NO_THIS!>this<!>
this<!UNRESOLVED_REFERENCE!>@a<!>
}
// FILE: f.kt
package closures
class A(val a:Int) {
class B() {
val x = this@B : B
val y = this@A : A
val z = this : B
val Int.xx : Int get() = this : Int
fun Char.xx() : Any {
this : Char
val <!UNUSED_VARIABLE!>a<!> = {Double.() -> this : Double + this@xx : Char}
val <!UNUSED_VARIABLE!>b<!> = @a{Double.() -> this@a : Double + this@xx : Char}
val <!UNUSED_VARIABLE!>c<!> = @a{() -> <!NO_THIS!>this@a<!> + this@xx : Char}
return (@a{Double.() -> this@a : Double + this@xx : Char})
}
}
}
@@ -0,0 +1,12 @@
// FILE: f.kt
class A() {
fun foo() : Unit {
this@A
this<!UNRESOLVED_REFERENCE!>@a<!>
this
}
val x = this@A.foo()
val y = this.foo()
val z = foo()
}
@@ -1,17 +1,5 @@
package example;
fun any(<!UNUSED_PARAMETER!>a<!> : Any) {}
fun notAnExpression() {
any(<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) // not an expression
if (<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) {} else {} // not an expression
val <!UNUSED_VARIABLE!>x<!> = <!SUPER_IS_NOT_AN_EXPRESSION!>super<!> // not an expression
<!NO_ELSE_IN_WHEN!>when<!> (1) {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> -> 1 // not an expression
}
}
trait T {
fun foo() {}
}
@@ -54,12 +42,6 @@ class A<E>() : C(), T {
}
}
fun foo() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.foo()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.foo()
}
trait G<T> {
fun foo() {}
}
@@ -79,11 +61,4 @@ class ERROR<E>() : <!UNRESOLVED_REFERENCE!>UR<!> {
fun test() {
super.<!UNRESOLVED_REFERENCE!>foo<!>()
}
}
// No supertype at all
class A1 {
fun test() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>.equals(null)
}
}
}
@@ -0,0 +1,5 @@
class Dup {
fun Dup() : Unit {
this<!AMBIGUOUS_LABEL!>@Dup<!>
}
}
@@ -0,0 +1,6 @@
// No supertype at all
class A1 {
fun test() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>.equals(null) // Call to an extension function
}
}
@@ -0,0 +1,5 @@
fun foo() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.foo()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.foo()
}
@@ -0,0 +1,12 @@
fun any(<!UNUSED_PARAMETER!>a<!> : Any) {}
fun notAnExpression() {
any(<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) // not an expression
if (<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) {} else {} // not an expression
val <!UNUSED_VARIABLE!>x<!> = <!SUPER_IS_NOT_AN_EXPRESSION!>super<!> // not an expression
when (1) {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> -> 1 // not an expression
else -> {}
}
}
@@ -0,0 +1,17 @@
class A(val a:Int) {
class B() {
fun Char.xx() : Any {
this : Char
val <!UNUSED_VARIABLE!>a<!> = {
Double.() ->
this : Double
this@xx : Char
this@B : B
this@A : A
}
val <!UNUSED_VARIABLE!>b<!> = @a{Double.() -> this@a : Double + this@xx : Char}
val <!UNUSED_VARIABLE!>c<!> = @a{() -> <!NO_THIS!>this@a<!> + this@xx : Char}
return (@a{Double.() -> this@a : Double + this@xx : Char})
}
}
}
@@ -0,0 +1,9 @@
class A(val a:Int) {
class B() {
val x = this@B : B
val y = this@A : A
val z = this : B
val Int.xx : Int get() = this : Int
}
}
@@ -0,0 +1,4 @@
fun foo1() : Unit {
<!NO_THIS!>this<!>
this<!UNRESOLVED_REFERENCE!>@a<!>
}
@@ -30,7 +30,7 @@ import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve;
@InnerTestClasses({JetDiagnosticsTestGenerated.Tests.class, JetDiagnosticsTestGenerated.Script.class})
public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEagerResolve {
@TestMetadata("compiler/testData/diagnostics/tests")
@InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.Enum.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Library.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.Tuples.class, Tests.Varargs.class})
@InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.Enum.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Library.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.ThisAndSuper.class, Tests.Tuples.class, Tests.Varargs.class})
public static class Tests extends AbstractDiagnosticsTestWithEagerResolve {
@TestMetadata("Abstract.kt")
public void testAbstract() throws Exception {
@@ -391,11 +391,6 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/QualifiedExpressions.kt");
}
@TestMetadata("QualifiedThis.kt")
public void testQualifiedThis() throws Exception {
doTest("compiler/testData/diagnostics/tests/QualifiedThis.kt");
}
@TestMetadata("RecursiveTypeInference.kt")
public void testRecursiveTypeInference() throws Exception {
doTest("compiler/testData/diagnostics/tests/RecursiveTypeInference.kt");
@@ -446,11 +441,6 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/StringTemplates.kt");
}
@TestMetadata("Super.kt")
public void testSuper() throws Exception {
doTest("compiler/testData/diagnostics/tests/Super.kt");
}
@TestMetadata("SupertypeListChecks.kt")
public void testSupertypeListChecks() throws Exception {
doTest("compiler/testData/diagnostics/tests/SupertypeListChecks.kt");
@@ -3489,6 +3479,59 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
}
@TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper")
public static class ThisAndSuper extends AbstractDiagnosticsTestWithEagerResolve {
public void testAllFilesPresentInThisAndSuper() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve", new File("compiler/testData/diagnostics/tests/thisAndSuper"), "kt", true);
}
@TestMetadata("ambigousLabelOnThis.kt")
public void testAmbigousLabelOnThis() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/ambigousLabelOnThis.kt");
}
@TestMetadata("QualifiedThis.kt")
public void testQualifiedThis() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/QualifiedThis.kt");
}
@TestMetadata("Super.kt")
public void testSuper() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/Super.kt");
}
@TestMetadata("superInExtensionFunctionCall.kt")
public void testSuperInExtensionFunctionCall() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/superInExtensionFunctionCall.kt");
}
@TestMetadata("superInToplevelFunction.kt")
public void testSuperInToplevelFunction() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.kt");
}
@TestMetadata("superIsNotAnExpression.kt")
public void testSuperIsNotAnExpression() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/superIsNotAnExpression.kt");
}
@TestMetadata("thisInFunctionLiterals.kt")
public void testThisInFunctionLiterals() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt");
}
@TestMetadata("thisInNestedClasses.kt")
public void testThisInNestedClasses() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/thisInNestedClasses.kt");
}
@TestMetadata("thisInToplevelFunction.kt")
public void testThisInToplevelFunction() throws Exception {
doTest("compiler/testData/diagnostics/tests/thisAndSuper/thisInToplevelFunction.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/tuples")
public static class Tuples extends AbstractDiagnosticsTestWithEagerResolve {
public void testAllFilesPresentInTuples() throws Exception {
@@ -3591,6 +3634,7 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
suite.addTestSuite(Shadowing.class);
suite.addTestSuite(Substitutions.class);
suite.addTestSuite(Subtyping.class);
suite.addTestSuite(ThisAndSuper.class);
suite.addTestSuite(Tuples.class);
suite.addTestSuite(Varargs.class);
return suite;