From 8be79b3f22ecba25a06445837077ed9bade80b91 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Mon, 12 Mar 2012 22:53:50 +0400 Subject: [PATCH] split some tests in JetDiagnosticsTest --- .../testData/diagnostics/tests/Objects.jet | 84 ------------------- .../diagnostics/tests/objects/Objects.jet | 29 +++++++ .../{ => objects}/ObjectsInheritance.jet | 0 .../tests/objects/ObjectsLocal.jet | 23 +++++ .../tests/objects/ObjectsNested.jet | 30 +++++++ .../ImportFromCurrentWithDifferentName.jet | 5 ++ .../ImportObjectHidesCurrentPackage.jet | 12 +++ .../tests/scopes/Imports-hidden.jet | 38 +-------- .../tests/scopes/ImportsConflicting.jet | 15 ++++ .../scopes/ImportsUselessSimpleImport.jet | 5 ++ .../scopes/ImportsUselessSimpleImport2.jet | 9 ++ 11 files changed, 132 insertions(+), 118 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/Objects.jet create mode 100644 compiler/testData/diagnostics/tests/objects/Objects.jet rename compiler/testData/diagnostics/tests/{ => objects}/ObjectsInheritance.jet (100%) create mode 100644 compiler/testData/diagnostics/tests/objects/ObjectsLocal.jet create mode 100644 compiler/testData/diagnostics/tests/objects/ObjectsNested.jet create mode 100644 compiler/testData/diagnostics/tests/scopes/ImportFromCurrentWithDifferentName.jet create mode 100644 compiler/testData/diagnostics/tests/scopes/ImportObjectHidesCurrentPackage.jet create mode 100644 compiler/testData/diagnostics/tests/scopes/ImportsConflicting.jet create mode 100644 compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport.jet create mode 100644 compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport2.jet diff --git a/compiler/testData/diagnostics/tests/Objects.jet b/compiler/testData/diagnostics/tests/Objects.jet deleted file mode 100644 index 6940f35cab2..00000000000 --- a/compiler/testData/diagnostics/tests/Objects.jet +++ /dev/null @@ -1,84 +0,0 @@ -// FILE: f.kt -package toplevelObjectDeclarations - open class Foo(y : Int) { - open fun foo() : Int = 1 - } - - class T : Foo {} - - object A : Foo { - val x : Int = 2 - - fun test() : Int { - return x + foo() - } - } - - object B : A {} - - val x = A.foo() - - val y = object : Foo(x) { - { - x + 12 - } - - override fun foo() : Int = 1 - } - - val z = y.foo() - -// FILE: f.kt -package nestedObejcts - object A { - val b = B - val d = A.B.A - - object B { - val a = A - val e = B.A - - object A { - val a = A - val b = B - val x = nestedObejcts.A.B.A - val y = this@A - } - } - - } - object B { - val b = B - val c = A.B - } - - val a = A - val b = B - val c = A.B - val d = A.B.A - val e = B.A.B - -// FILE: f.kt - -package localObjects - object A { - val x : Int = 0 - } - - open class Foo { - fun foo() : Int = 1 - } - - fun test() { - A.x - val b = object : Foo() { - } - b.foo() - - object B { - fun foo() {} - } - B.foo() - } - - val bb = B.foo() diff --git a/compiler/testData/diagnostics/tests/objects/Objects.jet b/compiler/testData/diagnostics/tests/objects/Objects.jet new file mode 100644 index 00000000000..27575534eb1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/Objects.jet @@ -0,0 +1,29 @@ +package toplevelObjectDeclarations + + open class Foo(y : Int) { + open fun foo() : Int = 1 + } + + class T : Foo {} + + object A : Foo { + val x : Int = 2 + + fun test() : Int { + return x + foo() + } + } + + object B : A {} + + val x = A.foo() + + val y = object : Foo(x) { + { + x + 12 + } + + override fun foo() : Int = 1 + } + + val z = y.foo() diff --git a/compiler/testData/diagnostics/tests/ObjectsInheritance.jet b/compiler/testData/diagnostics/tests/objects/ObjectsInheritance.jet similarity index 100% rename from compiler/testData/diagnostics/tests/ObjectsInheritance.jet rename to compiler/testData/diagnostics/tests/objects/ObjectsInheritance.jet diff --git a/compiler/testData/diagnostics/tests/objects/ObjectsLocal.jet b/compiler/testData/diagnostics/tests/objects/ObjectsLocal.jet new file mode 100644 index 00000000000..5c28facdbc0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/ObjectsLocal.jet @@ -0,0 +1,23 @@ +package localObjects + +object A { + val x : Int = 0 +} + +open class Foo { + fun foo() : Int = 1 +} + +fun test() { + A.x + val b = object : Foo() { + } + b.foo() + + object B { + fun foo() {} + } + B.foo() +} + +val bb = B.foo() diff --git a/compiler/testData/diagnostics/tests/objects/ObjectsNested.jet b/compiler/testData/diagnostics/tests/objects/ObjectsNested.jet new file mode 100644 index 00000000000..4a8961b6360 --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/ObjectsNested.jet @@ -0,0 +1,30 @@ +package nestedObejcts + +object A { + val b = B + val d = A.B.A + + object B { + val a = A + val e = B.A + + object A { + val a = A + val b = B + val x = nestedObejcts.A.B.A + val y = this@A + } + } + +} +object B { + val b = B + val c = A.B +} + +val a = A +val b = B +val c = A.B +val d = A.B.A +val e = B.A.B + diff --git a/compiler/testData/diagnostics/tests/scopes/ImportFromCurrentWithDifferentName.jet b/compiler/testData/diagnostics/tests/scopes/ImportFromCurrentWithDifferentName.jet new file mode 100644 index 00000000000..31fac95ce4c --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/ImportFromCurrentWithDifferentName.jet @@ -0,0 +1,5 @@ +package a + +import A as ER + +class A() diff --git a/compiler/testData/diagnostics/tests/scopes/ImportObjectHidesCurrentPackage.jet b/compiler/testData/diagnostics/tests/scopes/ImportObjectHidesCurrentPackage.jet new file mode 100644 index 00000000000..677f6f9f383 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/ImportObjectHidesCurrentPackage.jet @@ -0,0 +1,12 @@ +//FILE:a.kt +package a + +// no error is reported +import b.a + +fun foo() = a + +//FILE:b.kt +package b + +object a {} diff --git a/compiler/testData/diagnostics/tests/scopes/Imports-hidden.jet b/compiler/testData/diagnostics/tests/scopes/Imports-hidden.jet index 57b7483b3ff..498cd0ecdfb 100644 --- a/compiler/testData/diagnostics/tests/scopes/Imports-hidden.jet +++ b/compiler/testData/diagnostics/tests/scopes/Imports-hidden.jet @@ -1,45 +1,15 @@ //FILE:a.kt package a -import b.a -import c.a -import b - -import b.bar -import c.foo -import b.foo - -import A as ER -import B - -class A() {} -object B {} +import b.O +import c.O //FILE:b.kt package b -object a {} - -class B() { - class object { - object O {} - } -} - -fun foo() {} -fun bar() {} +object O {} //FILE:c.kt package c -fun a() {} - -object a {} - -class C() { - class object { - object O {} - } -} - -fun foo() {} \ No newline at end of file +object O {} diff --git a/compiler/testData/diagnostics/tests/scopes/ImportsConflicting.jet b/compiler/testData/diagnostics/tests/scopes/ImportsConflicting.jet new file mode 100644 index 00000000000..32368bda9c8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/ImportsConflicting.jet @@ -0,0 +1,15 @@ +//FILE:a.kt +package a + +import b.foo +import c.foo // TODO: need warning here + +//FILE:b.kt +package b + +fun foo() = 2 + +//FILE:c.kt +package c + +fun foo() = 1 diff --git a/compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport.jet b/compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport.jet new file mode 100644 index 00000000000..e0457aed5cb --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport.jet @@ -0,0 +1,5 @@ +package a + +import B + +object B {} diff --git a/compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport2.jet b/compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport2.jet new file mode 100644 index 00000000000..0349d8fcc54 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/ImportsUselessSimpleImport2.jet @@ -0,0 +1,9 @@ +// FILE:a.kt +package a + +import b + +// FILE:b.kt +package b + +class B()