diff --git a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java index 5f91659d132..a316dbc9fb2 100644 --- a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java +++ b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java @@ -87,9 +87,7 @@ public class SpecialFiles { excludedFiles.add("namespaceQualifiedMethod.kt"); // Cannot change package name excludedFiles.add("kt1482_2279.kt"); // Cannot change package name excludedFiles.add("kt1482.kt"); // Cannot change package name - excludedFiles.add("importFromClassObject.kt"); // Cannot find usages in Codegen tests excludedFiles.add("withtypeparams.kt"); // Cannot find usages in Codegen tests - excludedFiles.add("kt1113.kt"); // Commented excludedFiles.add("kt326.kt"); // Commented excludedFiles.add("kt1213.kt"); // Commented excludedFiles.add("kt882.kt"); // Commented diff --git a/compiler/testData/codegen/arrays/arrayGetAssignMultiIndex.kt b/compiler/testData/codegen/arrays/arrayGetAssignMultiIndex.kt new file mode 100644 index 00000000000..ece6e44a167 --- /dev/null +++ b/compiler/testData/codegen/arrays/arrayGetAssignMultiIndex.kt @@ -0,0 +1,11 @@ +fun Array.get(index1: Int, index2: Int) = this[index1 + index2] +fun Array.set(index1: Int, index2: Int, elem: String) { + this[index1 + index2] = elem +} + +fun box(): String { + val s = Array(1, { "" }) + s[1, -1] = "O" + s[2, -2] += "K" + return s[-3, 3] +} diff --git a/compiler/testData/codegen/arrays/arrayGetMultiIndex.kt b/compiler/testData/codegen/arrays/arrayGetMultiIndex.kt new file mode 100644 index 00000000000..3120a453ce1 --- /dev/null +++ b/compiler/testData/codegen/arrays/arrayGetMultiIndex.kt @@ -0,0 +1,11 @@ +fun Array.get(index1: Int, index2: Int) = this[index1 + index2] +fun Array.set(index1: Int, index2: Int, elem: String) { + this[index1 + index2] = elem +} + +fun box(): String { + val s = Array(1, { "" }) + s[1, -1] = "OK" + return s[-2, 2] +} + \ No newline at end of file diff --git a/compiler/testData/codegen/arrays/arrayPlusAssign.kt b/compiler/testData/codegen/arrays/arrayPlusAssign.kt new file mode 100644 index 00000000000..9a243990fd5 --- /dev/null +++ b/compiler/testData/codegen/arrays/arrayPlusAssign.kt @@ -0,0 +1,6 @@ +fun box(): String { + val s = IntArray(1) + s[0] = 5 + s[0] += 7 + return if (s[0] == 12) "OK" else "Fail ${s[0]}" +} diff --git a/compiler/testData/codegen/arrays/collectionAssignGetMultiIndex.kt b/compiler/testData/codegen/arrays/collectionAssignGetMultiIndex.kt new file mode 100644 index 00000000000..dac0cc4ee79 --- /dev/null +++ b/compiler/testData/codegen/arrays/collectionAssignGetMultiIndex.kt @@ -0,0 +1,14 @@ +import java.util.ArrayList + +fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] +fun ArrayList.set(index1: Int, index2: Int, elem: String) { + this[index1 + index2] = elem +} + +fun box(): String { + val s = ArrayList(1) + s.add("") + s[1, -1] = "O" + s[2, -2] += "K" + return s[2, -2] +} diff --git a/compiler/testData/codegen/arrays/collectionGetMultiIndex.kt b/compiler/testData/codegen/arrays/collectionGetMultiIndex.kt new file mode 100644 index 00000000000..33766188e6b --- /dev/null +++ b/compiler/testData/codegen/arrays/collectionGetMultiIndex.kt @@ -0,0 +1,13 @@ +import java.util.ArrayList + +fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] +fun ArrayList.set(index1: Int, index2: Int, elem: String) { + this[index1 + index2] = elem +} + +fun box(): String { + val s = ArrayList(1) + s.add("") + s[1, -1] = "OK" + return s[2, -2] +} diff --git a/compiler/testData/codegen/arrays/forEachBooleanArray.kt b/compiler/testData/codegen/arrays/forEachBooleanArray.kt new file mode 100644 index 00000000000..f0238410cc5 --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachBooleanArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in BooleanArray(5)) { + if (x != false) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachByteArray.kt b/compiler/testData/codegen/arrays/forEachByteArray.kt new file mode 100644 index 00000000000..1ae8205531a --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachByteArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in ByteArray(5)) { + if (x != 0.toByte()) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachCharArray.kt b/compiler/testData/codegen/arrays/forEachCharArray.kt new file mode 100644 index 00000000000..4b797671175 --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachCharArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in CharArray(5)) { + if (x != 0.toChar()) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachDoubleArray.kt b/compiler/testData/codegen/arrays/forEachDoubleArray.kt new file mode 100644 index 00000000000..c1a79f222a3 --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachDoubleArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in DoubleArray(5)) { + if (x != 0.toDouble()) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachFloatArray.kt b/compiler/testData/codegen/arrays/forEachFloatArray.kt new file mode 100644 index 00000000000..8245beab4ee --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachFloatArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in FloatArray(5)) { + if (x != 0.toFloat()) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachIntArray.kt b/compiler/testData/codegen/arrays/forEachIntArray.kt new file mode 100644 index 00000000000..53ce12dd393 --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachIntArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in IntArray(5)) { + if (x != 0) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachLongArray.kt b/compiler/testData/codegen/arrays/forEachLongArray.kt new file mode 100644 index 00000000000..6ed0259f765 --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachLongArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in LongArray(5)) { + if (x != 0.toLong()) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/forEachShortArray.kt b/compiler/testData/codegen/arrays/forEachShortArray.kt new file mode 100644 index 00000000000..a9145d42422 --- /dev/null +++ b/compiler/testData/codegen/arrays/forEachShortArray.kt @@ -0,0 +1,6 @@ +fun box(): String { + for (x in ShortArray(5)) { + if (x != 0.toShort()) return "Fail $x" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/hashMap.kt b/compiler/testData/codegen/arrays/hashMap.kt new file mode 100644 index 00000000000..9c344c50d00 --- /dev/null +++ b/compiler/testData/codegen/arrays/hashMap.kt @@ -0,0 +1,11 @@ +import java.util.HashMap + +fun HashMap.set(index: String, elem: Int?) { + this.put(index, elem) +} + +fun box(): String { + val s = HashMap() + s["239"] = 239 + return if (s["239"] == 239) "OK" else "Fail" +} diff --git a/compiler/testData/codegen/arrays/indices.kt b/compiler/testData/codegen/arrays/indices.kt new file mode 100644 index 00000000000..332b5add5fa --- /dev/null +++ b/compiler/testData/codegen/arrays/indices.kt @@ -0,0 +1,9 @@ +fun box(): String { + val a = Array(5, {it}) + val x = a.indices.iterator() + while (x.hasNext()) { + val i = x.next() + if (a[i] != i) return "Fail $i ${a[i]}" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/indicesChar.kt b/compiler/testData/codegen/arrays/indicesChar.kt new file mode 100644 index 00000000000..cd322a43478 --- /dev/null +++ b/compiler/testData/codegen/arrays/indicesChar.kt @@ -0,0 +1,9 @@ +fun box(): String { + val a = CharArray(5) + val x = a.indices.iterator() + while (x.hasNext()) { + val i = x.next() + if (a[i] != 0.toChar()) return "Fail $i ${a[i]}" + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iterator.kt b/compiler/testData/codegen/arrays/iterator.kt new file mode 100644 index 00000000000..eb8f84cbb04 --- /dev/null +++ b/compiler/testData/codegen/arrays/iterator.kt @@ -0,0 +1,9 @@ +fun box(): String { + val x = Array(5, { it } ).iterator() + var i = 0 + while (x.hasNext()) { + if (x.next() != i) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorBooleanArray.kt b/compiler/testData/codegen/arrays/iteratorBooleanArray.kt new file mode 100644 index 00000000000..753381f34f4 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorBooleanArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = BooleanArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorByteArray.kt b/compiler/testData/codegen/arrays/iteratorByteArray.kt new file mode 100644 index 00000000000..259eb5f3200 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorByteArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = ByteArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorByteArrayNextByte.kt b/compiler/testData/codegen/arrays/iteratorByteArrayNextByte.kt new file mode 100644 index 00000000000..61c458433a7 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorByteArrayNextByte.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = ByteArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.nextByte()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorCharArray.kt b/compiler/testData/codegen/arrays/iteratorCharArray.kt new file mode 100644 index 00000000000..525910d31e3 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorCharArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = CharArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorDoubleArray.kt b/compiler/testData/codegen/arrays/iteratorDoubleArray.kt new file mode 100644 index 00000000000..192625f22c6 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorDoubleArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = DoubleArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorFloatArray.kt b/compiler/testData/codegen/arrays/iteratorFloatArray.kt new file mode 100644 index 00000000000..4a5b86e694f --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorFloatArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = FloatArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorIntArray.kt b/compiler/testData/codegen/arrays/iteratorIntArray.kt new file mode 100644 index 00000000000..2dd09e3a59c --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorIntArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = IntArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorLongArray.kt b/compiler/testData/codegen/arrays/iteratorLongArray.kt new file mode 100644 index 00000000000..b1033002764 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorLongArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = LongArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorLongArrayNextLong.kt b/compiler/testData/codegen/arrays/iteratorLongArrayNextLong.kt new file mode 100644 index 00000000000..cc9cec5d570 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorLongArrayNextLong.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = LongArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.nextLong()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/iteratorShortArray.kt b/compiler/testData/codegen/arrays/iteratorShortArray.kt new file mode 100644 index 00000000000..49807e23720 --- /dev/null +++ b/compiler/testData/codegen/arrays/iteratorShortArray.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = ShortArray(5) + val x = a.iterator() + var i = 0 + while (x.hasNext()) { + if (a[i] != x.next()) return "Fail $i" + i++ + } + return "OK" +} diff --git a/compiler/testData/codegen/arrays/longAsIndex.kt b/compiler/testData/codegen/arrays/longAsIndex.kt new file mode 100644 index 00000000000..1d815615d16 --- /dev/null +++ b/compiler/testData/codegen/arrays/longAsIndex.kt @@ -0,0 +1,9 @@ +fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem } +fun IntArray.get(index: Long) = this[index.toInt()] + +fun box(): String { + var l = IntArray(1) + l[0.toLong()] = 4 + l[0.toLong()] += 6 + return if (l[0.toLong()] == 10) "OK" else "Fail" +} diff --git a/compiler/testData/codegen/classes/nonnullarray.kt b/compiler/testData/codegen/arrays/nonNullArray.kt similarity index 100% rename from compiler/testData/codegen/classes/nonnullarray.kt rename to compiler/testData/codegen/arrays/nonNullArray.kt diff --git a/compiler/testData/codegen/bridge.kt b/compiler/testData/codegen/bridges/overrideReturnType.kt similarity index 88% rename from compiler/testData/codegen/bridge.kt rename to compiler/testData/codegen/bridges/overrideReturnType.kt index 0aa86e3aa2a..f2d6eefa87f 100644 --- a/compiler/testData/codegen/bridge.kt +++ b/compiler/testData/codegen/bridges/overrideReturnType.kt @@ -1,5 +1,3 @@ -import java.lang.Integer - open class C { open fun f(): Any = "C f" } diff --git a/compiler/testData/codegen/controlStructures/forLoopMemberExtensionAll.kt b/compiler/testData/codegen/controlStructures/forLoopMemberExtensionAll.kt index aa5aaac571e..2b6265720d2 100644 --- a/compiler/testData/codegen/controlStructures/forLoopMemberExtensionAll.kt +++ b/compiler/testData/codegen/controlStructures/forLoopMemberExtensionAll.kt @@ -12,12 +12,14 @@ class X { fun test() { for (i in C()) { - System.out.println(i) + foo(i) } } } +fun foo(x: Int) {} + fun main(args: Array) { X().test() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/controlStructures/forLoopMemberExtensionHasNext.kt b/compiler/testData/codegen/controlStructures/forLoopMemberExtensionHasNext.kt index d1c285c08b6..b40a4b4920e 100644 --- a/compiler/testData/codegen/controlStructures/forLoopMemberExtensionHasNext.kt +++ b/compiler/testData/codegen/controlStructures/forLoopMemberExtensionHasNext.kt @@ -12,12 +12,14 @@ class X { fun test() { for (i in C()) { - System.out.println(i) + foo(i) } } } +fun foo(x: Int) {} + fun main(args: Array) { X().test() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/controlStructures/forLoopMemberExtensionNext.kt b/compiler/testData/codegen/controlStructures/forLoopMemberExtensionNext.kt index 2d34a62b758..7cc9fd656d2 100644 --- a/compiler/testData/codegen/controlStructures/forLoopMemberExtensionNext.kt +++ b/compiler/testData/codegen/controlStructures/forLoopMemberExtensionNext.kt @@ -12,12 +12,14 @@ class X { fun test() { for (i in C()) { - System.out.println(i) + foo(i) } } } +fun foo(x: Int) {} + fun main(args: Array) { X().test() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/controlStructures/forNullableIntArray.kt b/compiler/testData/codegen/controlStructures/forNullableIntArray.kt index 9f3749aa08d..e45df9c691e 100644 --- a/compiler/testData/codegen/controlStructures/forNullableIntArray.kt +++ b/compiler/testData/codegen/controlStructures/forNullableIntArray.kt @@ -9,7 +9,6 @@ fun box() : String { for (el in b) { sum = sum + (el ?: 0) } - System.out?.println(sum) if(sum != 10) return "b failed" return "OK" diff --git a/compiler/testData/codegen/controlStructures/ifInWhile.kt b/compiler/testData/codegen/controlStructures/ifInWhile.kt index f0dd043b966..01ff1ddb8af 100644 --- a/compiler/testData/codegen/controlStructures/ifInWhile.kt +++ b/compiler/testData/codegen/controlStructures/ifInWhile.kt @@ -4,7 +4,6 @@ fun box() : String { val processors = Runtime.getRuntime()!!.availableProcessors() var threadNum = 1 while(threadNum <= 1024) { - System.out?.println(threadNum) if(threadNum < 2 * processors) threadNum += 1 else diff --git a/compiler/testData/codegen/controlStructures/quicksort.kt b/compiler/testData/codegen/controlStructures/quicksort.kt index 96813b62c10..381a8cf44bb 100644 --- a/compiler/testData/codegen/controlStructures/quicksort.kt +++ b/compiler/testData/codegen/controlStructures/quicksort.kt @@ -34,9 +34,8 @@ fun box() : String { a[2*i+1] = -2*i-1 } a.quicksort() - for(i in 0..9) { - System.out?.print(a[i]) - System.out?.print(' ') + for(i in 0..a.size-2) { + if (a[i] > a[i+1]) return "Fail $i: ${a[i]} > ${a[i+1]}" } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/extensionFunctions/nested.kt b/compiler/testData/codegen/extensionFunctions/intCountDownLatchExtension.kt similarity index 100% rename from compiler/testData/codegen/extensionFunctions/nested.kt rename to compiler/testData/codegen/extensionFunctions/intCountDownLatchExtension.kt diff --git a/compiler/testData/codegen/functions/defaultargs3.kt b/compiler/testData/codegen/functions/defaultargs3.kt index 373dda9d48a..df755765779 100644 --- a/compiler/testData/codegen/functions/defaultargs3.kt +++ b/compiler/testData/codegen/functions/defaultargs3.kt @@ -4,7 +4,6 @@ class C() { fun testReceiver() : String { val res : String = "mama".toMyPrefixedString("111", "222") - System.out?.println(res) return res } diff --git a/compiler/testData/codegen/functions/namedargs.kt b/compiler/testData/codegen/functions/namedargs.kt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/compiler/testData/codegen/functions/nothisnoclosure.kt b/compiler/testData/codegen/functions/nothisnoclosure.kt index 3c7b59679f2..a334a7850a3 100644 --- a/compiler/testData/codegen/functions/nothisnoclosure.kt +++ b/compiler/testData/codegen/functions/nothisnoclosure.kt @@ -1,7 +1,9 @@ +fun foo(x: Int) {} + fun loop(var times : Int) { while(times > 0) { val u : (value : Int) -> Unit = { - System.out?.println(it) + foo(it) } u(times--) } diff --git a/compiler/testData/codegen/objects/importFromClassObject.kt b/compiler/testData/codegen/objects/importFromClassObject.kt deleted file mode 100644 index 775cc6ef789..00000000000 --- a/compiler/testData/codegen/objects/importFromClassObject.kt +++ /dev/null @@ -1,15 +0,0 @@ -import A.B.foo -import A.B.x - -class A() { - class object { - class B() { - class object { - val x = 1 - fun foo() = "2" - } - } - } -} - -fun box() = if (x == 1 && foo() == "2") "OK" else "fail" diff --git a/compiler/testData/codegen/patternMatching/nullableWhen.kt b/compiler/testData/codegen/patternMatching/nullableWhen.kt index fe59c3183ae..717b6a9c303 100644 --- a/compiler/testData/codegen/patternMatching/nullableWhen.kt +++ b/compiler/testData/codegen/patternMatching/nullableWhen.kt @@ -1,3 +1,6 @@ +// KT-2148 + + fun f(p: Int?): Int { return when(p) { null -> 3 diff --git a/compiler/testData/codegen/regressions/kt1649_1.kt b/compiler/testData/codegen/regressions/kt1649_1.kt index d3691a55633..ef16a4645a6 100644 --- a/compiler/testData/codegen/regressions/kt1649_1.kt +++ b/compiler/testData/codegen/regressions/kt1649_1.kt @@ -6,4 +6,13 @@ fun test(a : A) { if (a.method != null) { a.method!!() } -} \ No newline at end of file +} + +class B : A { + override val method = { } +} + +fun box(): String { + test(B()) + return "OK" +} diff --git a/compiler/testData/codegen/regressions/kt1649_2.kt b/compiler/testData/codegen/regressions/kt1649_2.kt index e76f4994147..e75d9cb4b62 100644 --- a/compiler/testData/codegen/regressions/kt1649_2.kt +++ b/compiler/testData/codegen/regressions/kt1649_2.kt @@ -6,4 +6,13 @@ fun test(a : A) { if (a.method != null) { a.method!!() } -} \ No newline at end of file +} + +class B : A { + override val method = { } +} + +fun box(): String { + test(B()) + return "OK" +} diff --git a/compiler/testData/codegen/regressions/kt247.kt b/compiler/testData/codegen/regressions/kt247.kt index af13811dee9..55a7fbe74f8 100644 --- a/compiler/testData/codegen/regressions/kt247.kt +++ b/compiler/testData/codegen/regressions/kt247.kt @@ -12,15 +12,14 @@ fun t2() : Boolean { fun t3() { val d: D = D("s") - System.out?.println(d?.s) - System.out?.println(d?.s == "s") //prints true - System.out?.println(d) //ok + val x = d?.s + if (!(d?.s == "s")) throw AssertionError() } fun t4() { val e: E? = E() - System.out?.println(e?.bar() == e) //verify error - System.out?.println(e?.foo()) //verify error + if (!(e?.bar() == e)) throw AssertionError() + val x = e?.foo() } fun box() : String { diff --git a/compiler/testData/codegen/regressions/kt2498.kt b/compiler/testData/codegen/regressions/kt2498.kt index e52b96a0aa9..715caf3b011 100644 --- a/compiler/testData/codegen/regressions/kt2498.kt +++ b/compiler/testData/codegen/regressions/kt2498.kt @@ -1,6 +1,6 @@ -import java.util.LinkedList +import java.util.ArrayList -open class BaseStringList: LinkedList() { +open class BaseStringList: ArrayList() { } class StringList: BaseStringList() { @@ -14,6 +14,6 @@ fun box(): String { myStringList.add("first element") if (myStringList.get(0) != "StringList.get()") return "Fail #1" if ((myStringList: BaseStringList).get(0) != "StringList.get()") return "Fail #2" - if ((myStringList: LinkedList).get(0) != "StringList.get()") return "Fail #3" + if ((myStringList: ArrayList).get(0) != "StringList.get()") return "Fail #3" return "OK" } diff --git a/compiler/testData/codegen/regressions/kt326.kt b/compiler/testData/codegen/regressions/kt326.kt index 2a74a6abb35..117274a76dd 100644 --- a/compiler/testData/codegen/regressions/kt326.kt +++ b/compiler/testData/codegen/regressions/kt326.kt @@ -1,7 +1,5 @@ -package test - -class List(len: Int, cls : java.lang.Class) { - val a : Array = Array(len) +class List(len: Int) { + val a = Array(len) { null } fun reverse() { var i = 0 @@ -17,19 +15,19 @@ class List(len: Int, cls : java.lang.Class) { fun box() : String { val d = List(1) d.a[0] = 10 - println(d.a[0]) + checkEquals(d.a[0], 10) val a = List(1) a.a[0] = "1" - println(a.a[0]) + checkEquals(a.a[0], "1") val b = List(1) b.a[0] = 10 - println(b.a[0]) + checkEquals(b.a[0], 10) val c = List>(1) c.a[0] = Array(4,{-1}) - println(c.a[0]?.size) + checkEquals(c.a[0]?.size, 4) val e = List(5) e.a[0] = 0 @@ -38,12 +36,16 @@ fun box() : String { e.a[3] = 3 e.a[4] = 4 e.reverse() - for(el in e.a) - println(el) + for (i in 0..4) + checkEquals(e.a[i], 4-i) return "OK" } -fun println(s : Any?) { - System.out?.println(s); +fun checkEquals(a: Any?, b: Any?) { + if (a != b) throw AssertionError("Expected: $b, actual: $a") +} + +fun main(args: Array) { + println(box()) } diff --git a/compiler/testData/codegen/regressions/kt581.kt b/compiler/testData/codegen/regressions/kt581.kt index 2ff762d2492..8773363c8cd 100644 --- a/compiler/testData/codegen/regressions/kt581.kt +++ b/compiler/testData/codegen/regressions/kt581.kt @@ -15,7 +15,8 @@ fun box() : String { for (i in vals.indices) for (j in i..vals.lastIndex()) diffs.add(vals[i] - vals[j]) - System.out?.println(diffs.size()) + val size = diffs.size() + if (size != 8) return "Fail $size" return "OK" } diff --git a/compiler/testData/codegen/regressions/kt865.kt b/compiler/testData/codegen/regressions/kt865.kt index c47829aa612..794ae5de8b9 100644 --- a/compiler/testData/codegen/regressions/kt865.kt +++ b/compiler/testData/codegen/regressions/kt865.kt @@ -1,7 +1,7 @@ import java.util.* class Template() { - val collected = LinkedList() + val collected = ArrayList() fun String.plus() { collected.add(this@plus) diff --git a/compiler/testData/codegen/super/basicproperty.kt b/compiler/testData/codegen/super/basicproperty.kt index 196ed3f40b0..f1fab6ffe23 100644 --- a/compiler/testData/codegen/super/basicproperty.kt +++ b/compiler/testData/codegen/super/basicproperty.kt @@ -16,7 +16,9 @@ class N() : M() { fun box(): String { val n = N() - System.out?.println("a: " + n.a + " b: " + n.b + " superb: " + n.superb) + n.a + n.b + n.superb if (n.b == 3 && n.a == 4 && n.superb == 3) return "OK"; return "fail"; -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/super/traitproperty.kt b/compiler/testData/codegen/super/traitproperty.kt index 6b61b588ef4..820d99402a7 100644 --- a/compiler/testData/codegen/super/traitproperty.kt +++ b/compiler/testData/codegen/super/traitproperty.kt @@ -23,7 +23,9 @@ class N() : M { fun box(): String { val n = N() - System.out?.println("a: " + n.a + " b: " + n.b + " superb: " + n.superb) + n.a + n.b + n.superb if (n.b == 3 && n.a == 4 && n.superb == 3) return "OK"; return "fail"; -} \ No newline at end of file +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/AnnotationGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/AnnotationGenTest.java index a571db0ef1b..a4da3e489e6 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/AnnotationGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/AnnotationGenTest.java @@ -53,7 +53,6 @@ public class AnnotationGenTest extends CodegenTestCase { public void testPropSetter() throws NoSuchFieldException, NoSuchMethodException { loadText("var x = 0\n" + "[Deprecated] set"); -// System.out.println(generateToText()); Class aClass = generateNamespaceClass(); assertNull(aClass.getDeclaredMethod("getX").getAnnotation(Deprecated.class)); assertNotNull(aClass.getDeclaredMethod("setX", int.class).getAnnotation(Deprecated.class)); diff --git a/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java index dc81238015d..6725f67c77c 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java @@ -21,25 +21,25 @@ import org.jetbrains.jet.ConfigurationKind; import java.lang.reflect.Method; public class ArrayGenTest extends CodegenTestCase { - @Override protected void setUp() throws Exception { super.setUp(); createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); } - public void testKt238() throws Exception { + public void testKt238() { blackBoxFile("regressions/kt238.kt"); } - public void testKt326() throws Exception { - // blackBoxFile("regressions/kt326.kt"); - // System.out.println(generateToText()); + public void testKt326() { + // Disabled: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer; + /* + blackBoxFile("regressions/kt326.kt"); + */ } - public void testKt779() throws Exception { + public void testKt779() { blackBoxFile("regressions/kt779.kt"); - // System.out.println(generateToText()); } public void testCreateMultiInt() throws Exception { @@ -69,244 +69,141 @@ public class ArrayGenTest extends CodegenTestCase { loadText("fun foo() = Array> (5, { Array(0,{\"\"}) })"); Method foo = generateFunction(); Object invoke = foo.invoke(null); - System.out.println(invoke.getClass()); assertTrue(invoke instanceof Object[]); } public void testCreateMultiGenerics() throws Exception { - // loadText("class L() { val a = Array(5) } fun foo() = L.a"); - // System.out.println(generateToText()); - // Method foo = generateFunction(); - // Object invoke = foo.invoke(null); - // System.out.println(invoke.getClass()); - // assertTrue(invoke.getClass() == Object[].class); + // Disabled: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer; + /* + loadText("class L() { val a = Array(5) { null } } fun foo() = L().a"); + System.out.println(generateToText()); + Method foo = generateFunction(); + Object invoke = foo.invoke(null); + assertTrue(invoke.getClass() == Object[].class); + */ } public void testIntGenerics() throws Exception { loadText("class L(var a : T) {} fun foo() = L(5).a"); - //System.out.println(generateToText()); Method foo = generateFunction(); Object invoke = foo.invoke(null); - System.out.println(invoke.getClass()); assertTrue(invoke instanceof Integer); } - public void testIterator() throws Exception { - loadText("fun box() { val x = Array(5, { it } ).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIterator() { + blackBoxFile("arrays/iterator.kt"); } - public void testPrimitiveIterator() throws Exception { - loadText("fun box() { val x = ByteArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.nextByte()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorLongArrayNextLong() { + blackBoxFile("arrays/iteratorLongArrayNextLong.kt"); } - public void testPrimitiveIteratorByte() throws Exception { - loadText("fun box() { for(x in ByteArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorByteArrayNextByte() { + blackBoxFile("arrays/iteratorByteArrayNextByte.kt"); } - public void testPrimitiveIteratorShort() throws Exception { - loadText("fun box() { for(x in ShortArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachBooleanArray() { + blackBoxFile("arrays/forEachBooleanArray.kt"); } - public void testPrimitiveIteratorInt() throws Exception { - loadText("fun box() { for(x in IntArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachByteArray() { + blackBoxFile("arrays/forEachByteArray.kt"); } - public void testPrimitiveIteratorLong() throws Exception { - loadText("fun box() { for(x in LongArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachCharArray() { + blackBoxFile("arrays/forEachCharArray.kt"); } - public void testPrimitiveIteratorFloat() throws Exception { - loadText("fun box() { for(x in FloatArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachDoubleArray() { + blackBoxFile("arrays/forEachDoubleArray.kt"); } - public void testPrimitiveIteratorDouble() throws Exception { - loadText("fun box() { for(x in DoubleArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachFloatArray() { + blackBoxFile("arrays/forEachFloatArray.kt"); } - public void testPrimitiveIteratorChar() throws Exception { - loadText("fun box() { for(x in CharArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachIntArray() { + blackBoxFile("arrays/forEachIntArray.kt"); } - public void testPrimitiveIteratorBoolean() throws Exception { - loadText("fun box() { for(x in BooleanArray(5)) { java.lang.System.out?.println(x) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachLongArray() { + blackBoxFile("arrays/forEachLongArray.kt"); } - public void testLongIterator() throws Exception { - loadText("fun box() { val x = LongArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.nextLong()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testForEachShortArray() { + blackBoxFile("arrays/forEachShortArray.kt"); } - public void testCharIterator() throws Exception { - loadText("fun box() { val x = CharArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorBooleanArray() { + blackBoxFile("arrays/iteratorBooleanArray.kt"); } - public void testByteIterator() throws Exception { - loadText("fun box() { val x = ByteArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorByteArray() { + blackBoxFile("arrays/iteratorByteArray.kt"); } - public void testShortIterator() throws Exception { - loadText("fun box() { val x = ShortArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorCharArray() { + blackBoxFile("arrays/iteratorCharArray.kt"); } - public void testIntIterator() throws Exception { - loadText("fun box() { val x = IntArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorDoubleArray() { + blackBoxFile("arrays/iteratorDoubleArray.kt"); } - public void testLongIterator2() throws Exception { - loadText("fun box() { val x = LongArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorFloatArray() { + blackBoxFile("arrays/iteratorFloatArray.kt"); } - public void testFloatIterator() throws Exception { - loadText("fun box() { val x = FloatArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorIntArray() { + blackBoxFile("arrays/iteratorIntArray.kt"); } - public void testDoubleIterator() throws Exception { - loadText("fun box() { val x = ShortArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorLongArray() { + blackBoxFile("arrays/iteratorLongArray.kt"); } - public void testBooleanIterator() throws Exception { - loadText("fun box() { val x = BooleanArray(5).iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIteratorShortArray() { + blackBoxFile("arrays/iteratorShortArray.kt"); } - public void testArrayIndices() throws Exception { - loadText( - "fun box() { val x = Array(5, {it}).indices.iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testArrayIndices() { + blackBoxFile("arrays/indices.kt"); } - public void testCharIndices() throws Exception { - loadText("fun box() { val x = CharArray(5).indices.iterator(); while(x.hasNext()) { java.lang.System.out?.println(x.next()) } }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - foo.invoke(null); + public void testIndicesChar() { + blackBoxFile("arrays/indicesChar.kt"); } - public void testCollectionPlusAssign() throws Exception { + public void testCollectionPlusAssign() { blackBoxFile("regressions/kt33.kt"); } - public void testArrayPlusAssign() throws Exception { - loadText("fun box() : Int { val s = IntArray(1); s [0] = 5; s[0] += 7; return s[0] }"); - // System.out.println(generateToText()); - Method foo = generateFunction(); - assertTrue((Integer) foo.invoke(null) == 12); + public void testArrayPlusAssign() { + blackBoxFile("arrays/arrayPlusAssign.kt"); } - public void testCollectionAssignGetMultiIndex() throws Exception { - loadText("import java.util.ArrayList\n" + - "fun box() : String { val s = ArrayList(1); s.add(\"\"); s [1, -1] = \"5\"; s[2, -2] += \"7\"; return s[2,-2] }\n" + - "fun ArrayList.get(index1: Int, index2 : Int) = this[index1+index2]!!\n" + - "fun ArrayList.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem }\n"); - // System.out.println(generateToText()); - Method foo = generateFunction("box"); - assertTrue(foo.invoke(null).equals("57")); + public void testCollectionAssignGetMultiIndex() { + blackBoxFile("arrays/collectionAssignGetMultiIndex.kt"); } - public void testArrayGetAssignMultiIndex() throws Exception { - loadText( - "fun box() : String? { val s = Array(1,{ \"\" }); s [1, -1] = \"5\"; s[2, -2] += \"7\"; return s[-3,3] }\n" + - "fun Array.get(index1: Int, index2 : Int) = this[index1+index2]\n" + - "fun Array.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem\n }"); - // System.out.println(generateToText()); - Method foo = generateFunction("box"); - assertTrue(foo.invoke(null).equals("57")); + public void testArrayGetAssignMultiIndex() { + blackBoxFile("arrays/arrayGetAssignMultiIndex.kt"); } - public void testCollectionGetMultiIndex() throws Exception { - loadText("import java.util.ArrayList\n" + - "fun box() : String { val s = ArrayList(1); s.add(\"\"); s [1, -1] = \"5\"; return s[2, -2] }\n" + - "fun ArrayList.get(index1: Int, index2 : Int) = this[index1+index2]!!\n" + - "fun ArrayList.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem }\n"); - // System.out.println(generateToText()); - Method foo = generateFunction("box"); - assertTrue(foo.invoke(null).equals("5")); + public void testCollectionGetMultiIndex() { + blackBoxFile("arrays/collectionGetMultiIndex.kt"); } - public void testArrayGetMultiIndex() throws Exception { - loadText( - "fun box() : String? { val s = Array(1,{ \"\" }); s [1, -1] = \"5\"; return s[-2, 2] }\n" + - "fun Array.get(index1: Int, index2 : Int) = this[index1+index2]\n" + - "fun Array.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem\n }"); - // System.out.println(generateToText()); - Method foo = generateFunction("box"); - assertTrue(foo.invoke(null).equals("5")); + public void testArrayGetMultiIndex() { + blackBoxFile("arrays/arrayGetMultiIndex.kt"); } - public void testMap() throws Exception { - loadText( - "fun box() : Int? { val s = java.util.HashMap(); s[\"239\"] = 239; return s[\"239\"] }\n" + - "fun java.util.HashMap.set(index: String, elem: Int?) { this.put(index, elem) }"); - // System.out.println(generateToText()); - Method foo = generateFunction("box"); - assertTrue((Integer) foo.invoke(null) == 239); + public void testHashMap() { + blackBoxFile("arrays/hashMap.kt"); } - public void testLongDouble() throws Exception { - loadText( - "fun box() : Int { var l = IntArray(1); l[0.toLong()] = 4; l[0.toLong()] += 6; return l[0.toLong()];}\n" + - "fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem }\n" + - "fun IntArray.get(index: Long) = this[index.toInt()]"); - // System.out.println(generateToText()); - Method foo = generateFunction("box"); - assertTrue((Integer) foo.invoke(null) == 10); + public void testLongAsIndex() { + blackBoxFile("arrays/longAsIndex.kt"); } public void testKt503() { @@ -315,25 +212,21 @@ public class ArrayGenTest extends CodegenTestCase { public void testKt602() { blackBoxFile("regressions/kt602.kt"); - // System.out.println(generateToText()); } public void testKt950() { blackBoxFile("regressions/kt950.kt"); } - public void testKt594() throws Exception { - loadFile("regressions/kt594.kt"); - // System.out.println(generateToText()); - blackBox(); + public void testKt594() { + blackBoxFile("regressions/kt594.kt"); } - public void testNonNullArray() throws Exception { - blackBoxFile("classes/nonnullarray.kt"); - // System.out.println(generateToText()); + public void testNonNullArray() { + blackBoxFile("arrays/nonNullArray.kt"); } - public void testArrayCast() throws Exception { + public void testArrayCast() { blackBoxFile("regressions/kt2997.kt"); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.java index 245dfdf588f..f3ab4f1a358 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.java @@ -19,184 +19,153 @@ package org.jetbrains.jet.codegen; import org.jetbrains.jet.ConfigurationKind; public class BridgeMethodGenTest extends CodegenTestCase { - - public void testBridgeMethod () throws Exception { + @Override + protected void setUp() throws Exception { + super.setUp(); createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); - blackBoxFile("bridge.kt"); + } + + public void testOverrideReturnType() { + blackBoxFile("bridges/overrideReturnType.kt"); } public void testKt1959() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt1959.kt"); } public void testDelegation() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/delegation.kt"); } public void testDelegationProperty() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/delegationProperty.kt"); } public void testDelegationToTraitImpl() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/delegationToTraitImpl.kt"); } public void testDiamond() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/diamond.kt"); } public void testLongChainOneBridge() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/longChainOneBridge.kt"); } public void testManyTypeArgumentsSubstitutedSuccessively() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/manyTypeArgumentsSubstitutedSuccessively.kt"); } public void testMethodFromTrait() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/methodFromTrait.kt"); } public void testOverrideAbstractProperty() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/overrideAbstractProperty.kt"); } public void testSimple() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/simple.kt"); } public void testSimpleEnum() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/simpleEnum.kt"); } public void testSimpleGenericMethod() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/simpleGenericMethod.kt"); } public void testSimpleObject() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/simpleObject.kt"); } public void testSimpleReturnType() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/simpleReturnType.kt"); } public void testSimpleUpperBound() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/simpleUpperBound.kt"); } public void testSubstitutionInSuperClass() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClass.kt"); } public void testSubstitutionInSuperClassDelegation() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassDelegation.kt"); } public void testSubstitutionInSuperClassAbstractFun() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassAbstractFun.kt"); } public void testSubstitutionInSuperClassBoundedTypeArguments() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassBoundedTypeArguments.kt"); } public void testSubstitutionInSuperClassEnum() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassEnum.kt"); } public void testSubstitutionInSuperClassGenericMethod() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassGenericMethod.kt"); } public void testSubstitutionInSuperClassObject() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassObject.kt"); } public void testSubstitutionInSuperClassUpperBound() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassUpperBound.kt"); } public void testTwoParentsWithDifferentMethodsTwoBridges() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/twoParentsWithDifferentMethodsTwoBridges.kt"); } public void testTwoParentsWithTheSameMethodOneBridge() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/twoParentsWithTheSameMethodOneBridge.kt"); } public void testKt2498() { - createEnvironmentWithFullJdk(); blackBoxFile("regressions/kt2498.kt"); } public void testKt1939() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt1939.kt"); } public void testKt2702() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2702.kt"); } public void testKt2920() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2920.kt"); } public void testSubstitutionInSuperClassProperty() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/substitutionInSuperClassProperty.kt"); } public void testPropertySetter() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/propertySetter.kt"); } public void testPropertyDiamond() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/propertyDiamond.kt"); } public void testPropertyAccessorsWithoutBody() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/propertyAccessorsWithoutBody.kt"); } public void testPropertyInConstructor() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("bridges/propertyInConstructor.kt"); } public void testKt2833() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2833.kt"); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java index 22404d84ec9..615006d31ec 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java @@ -19,44 +19,41 @@ package org.jetbrains.jet.codegen; import org.jetbrains.jet.ConfigurationKind; public class ClosuresGenTest extends CodegenTestCase { - @Override protected void setUp() throws Exception { super.setUp(); createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); } - public void testSimplestClosure() throws Exception { + public void testSimplestClosure() { blackBoxFile("classes/simplestClosure.kt"); -// System.out.println(generateToText()); } - public void testSimplestClosureAndBoxing() throws Exception { + public void testSimplestClosureAndBoxing() { blackBoxFile("classes/simplestClosureAndBoxing.kt"); } - public void testClosureWithParameter() throws Exception { + public void testClosureWithParameter() { blackBoxFile("classes/closureWithParameter.kt"); } - public void testClosureWithParameterAndBoxing() throws Exception { + public void testClosureWithParameterAndBoxing() { blackBoxFile("classes/closureWithParameterAndBoxing.kt"); } - public void testExtensionClosure() throws Exception { + public void testExtensionClosure() { blackBoxFile("classes/extensionClosure.kt"); } - public void testEnclosingLocalVariable() throws Exception { + public void testEnclosingLocalVariable() { blackBoxFile("classes/enclosingLocalVariable.kt"); -// System.out.println(generateToText()); } - public void testDoubleEnclosedLocalVariable() throws Exception { + public void testDoubleEnclosedLocalVariable() { blackBoxFile("classes/doubleEnclosedLocalVariable.kt"); } - public void testEnclosingThis() throws Exception { + public void testEnclosingThis() { blackBoxFile("classes/enclosingThis.kt"); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java b/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java index 41bb96957fe..e00f1ae72ad 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java @@ -18,32 +18,31 @@ package org.jetbrains.jet.codegen; import org.jetbrains.jet.ConfigurationKind; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; public class ControlStructuresTest extends CodegenTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + } + @Override protected String getPrefix() { return "controlStructures"; } public void testIf() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); - -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(15, main.invoke(null, true)); assertEquals(20, main.invoke(null, false)); } public void testSingleBranchIf() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); - -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(15, main.invoke(null, true)); assertEquals(20, main.invoke(null, false)); @@ -61,43 +60,32 @@ public class ControlStructuresTest extends CodegenTestCase { factorialTest("controlStructures/break.kt"); } - /* - public void testInRangeConditionsInWhen() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testInRangeConditionsInWhen() { blackBoxFile("controlStructures/inRangeConditionsInWhen.kt"); } - */ - private void factorialTest(final String name) throws IllegalAccessException, InvocationTargetException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + private void factorialTest(String name) throws Exception { loadFile(name); - -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(6, main.invoke(null, 3)); assertEquals(120, main.invoke(null, 5)); } public void testContinue() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(3, main.invoke(null, 4)); assertEquals(7, main.invoke(null, 5)); } public void testIfNoElse() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(5, main.invoke(null, 5, true)); assertEquals(10, main.invoke(null, 5, false)); } public void testCondJumpOnStack() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("import java.lang.Boolean as jlBoolean; fun foo(a: String): Int = if (jlBoolean.parseBoolean(a)) 5 else 10"); final Method main = generateFunction(); assertEquals(5, main.invoke(null, "true")); @@ -105,18 +93,14 @@ public class ControlStructuresTest extends CodegenTestCase { } public void testFor() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); List args = Arrays.asList("IntelliJ", " ", "IDEA"); assertEquals("IntelliJ IDEA", main.invoke(null, args)); } public void testIfBlock() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); List args = Arrays.asList("IntelliJ", " ", "IDEA"); assertEquals("TTT", main.invoke(null, args)); @@ -125,16 +109,13 @@ public class ControlStructuresTest extends CodegenTestCase { } public void testForInArray() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); String[] args = new String[] { "IntelliJ", " ", "IDEA" }; assertEquals("IntelliJ IDEA", main.invoke(null, new Object[] { args })); } public void testForInRange() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("fun foo(sb: StringBuilder) { for(x in 1..4) sb.append(x) }"); final Method main = generateFunction(); StringBuilder stringBuilder = new StringBuilder(); @@ -143,96 +124,66 @@ public class ControlStructuresTest extends CodegenTestCase { } public void testThrowCheckedException() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("fun foo() { throw Exception(); }"); final Method main = generateFunction(); - boolean caught = false; - try { - main.invoke(null); - } catch (InvocationTargetException e) { - if (e.getTargetException().getClass() == Exception.class) { - caught = true; - } - } - assertTrue(caught); + assertThrows(main, Exception.class, null); } public void testTryCatch() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals("no message", main.invoke(null, "0")); assertEquals("For input string: \"a\"", main.invoke(null, "a")); } public void testTryFinally() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); -// System.out.println(generateToText()); final Method main = generateFunction(); StringBuilder sb = new StringBuilder(); main.invoke(null, sb, "9"); assertEquals("foo9bar", sb.toString()); sb = new StringBuilder(); - boolean caught = false; - try { - main.invoke(null, sb, "x"); - } - catch(InvocationTargetException e) { - caught = e.getTargetException() instanceof NumberFormatException; - } - assertTrue(caught); + assertThrows(main, NumberFormatException.class, null, sb, "x"); assertEquals("foobar", sb.toString()); } - public void testForUserType() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForUserType() { blackBoxFile("controlStructures/forUserType.kt"); } - public void testForLoopMemberExtensionNext() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForLoopMemberExtensionNext() { blackBoxFile("controlStructures/forLoopMemberExtensionNext.kt"); } - public void testForLoopMemberExtensionHasNext() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForLoopMemberExtensionHasNext() { blackBoxFile("controlStructures/forLoopMemberExtensionHasNext.kt"); } - public void testForLoopMemberExtensionAll() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForLoopMemberExtensionAll() { blackBoxFile("controlStructures/forLoopMemberExtensionAll.kt"); } - public void testForIntArray() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForIntArray() { blackBoxFile("controlStructures/forIntArray.kt"); } - public void testForPrimitiveIntArray() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForPrimitiveIntArray() { blackBoxFile("controlStructures/forPrimitiveIntArray.kt"); } - public void testForNullableIntArray() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testForNullableIntArray() { blackBoxFile("controlStructures/forNullableIntArray.kt"); } public void testForIntRange() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/forIntRange.kt"); } - public void testKt237() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt237() { blackBoxFile("regressions/kt237.kt"); } public void testCompareToZero() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("fun foo(a: Int, b: Int): Boolean = a == 0 && b != 0 && 0 == a && 0 != b"); String text = generateToText(); /* @@ -248,247 +199,171 @@ public class ControlStructuresTest extends CodegenTestCase { } public void testCompareBoxedIntegerToZero() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/compareBoxedIntegerToZero.kt"); } public void testCompareToNull() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("fun foo(a: String?, b: String?): Boolean = a == null && b !== null && null == a && null !== b"); String text = generateToText(); assertTrue(!text.contains("java/lang/Object.equals")); - //System.out.println(text); final Method main = generateFunction(); assertEquals(true, main.invoke(null, null, "lala")); assertEquals(false, main.invoke(null, null, null)); } public void testCompareToNonnullableEq() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("fun foo(a: String?, b: String): Boolean = a == b || b == a"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(false, main.invoke(null, null, "lala")); assertEquals(true, main.invoke(null, "papa", "papa")); } public void testCompareToNonnullableNotEq() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("fun foo(a: String?, b: String): Boolean = a != b"); String text = generateToText(); -// System.out.println(text); assertTrue(text.contains("IXOR")); final Method main = generateFunction(); assertEquals(true, main.invoke(null, null, "lala")); assertEquals(false, main.invoke(null, "papa", "papa")); } - public void testKt299() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt299() { blackBoxFile("regressions/kt299.kt"); } - public void testKt416() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt416() { blackBoxFile("regressions/kt416.kt"); -// System.out.println(generateToText()); } - public void testKt513() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt513() { blackBoxFile("regressions/kt513.kt"); } - public void testKt434() throws Exception { - createEnvironmentWithFullJdk(); - blackBoxFile("regressions/kt434.kt"); - } - - public void testKt769() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt769() { blackBoxFile("regressions/kt769.kt"); -// System.out.println(generateToText()); } - public void testKt773() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt773() { blackBoxFile("regressions/kt773.kt"); -// System.out.println(generateToText()); } - public void testKt772() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt772() { blackBoxFile("regressions/kt772.kt"); -// System.out.println(generateToText()); } - public void testKt870() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt870() { blackBoxFile("regressions/kt870.kt"); -// System.out.println(generateToText()); } - public void testKt958() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt958() { blackBoxFile("regressions/kt958.kt"); -// System.out.println(generateToText()); } - public void testQuicksort() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testQuicksort() { blackBoxFile("controlStructures/quicksort.kt"); -// System.out.println(generateToText()); } - public void testSynchronized() throws Exception { - createEnvironmentWithFullJdk(); - blackBoxFile("controlStructures/sync.kt"); -// System.out.println(generateToText()); - } - - public void testIfInWhile() throws Exception { - createEnvironmentWithFullJdk(); - blackBoxFile("controlStructures/ifInWhile.kt"); -// System.out.println(generateToText()); - } - - public void testKt1076() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL); - blackBoxFile("regressions/kt1076.kt"); - } - - public void testKt998() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt998() { blackBoxFile("regressions/kt998.kt"); } - public void testContinueInFor() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS); + public void testContinueInFor() { blackBoxFile("controlStructures/continueInFor.kt"); } - public void testContinueToLabelInFor() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS); + public void testContinueToLabelInFor() { blackBoxFile("controlStructures/continueToLabelInFor.kt"); } - public void testKt628() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt628() { blackBoxFile("regressions/kt628.kt"); } - public void testKt1441() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1441() { blackBoxFile("regressions/kt1441.kt"); } - public void testKt2147() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2147() { blackBoxFile("regressions/kt2147.kt"); } public void testIfDummy() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt1899.kt"); } public void testKt1742() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt1742.kt"); } public void testKt2062() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2062.kt"); } public void testKt910() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt910.kt"); } public void testKt1688() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt1688.kt"); } - public void testKt2423() { - createEnvironmentWithFullJdk(); - blackBoxFile("regressions/kt2423.kt"); - } - public void testKt2416() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2416.kt"); } public void testKt2291() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2291.kt"); } public void testKt2259() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2259.kt"); } public void testKt2577() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2577.kt"); } public void testTryCatchFinallyChain() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/tryCatchFinallyChain.kt"); } public void testKt2597() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2597.kt"); } public void testKt2598() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt2598.kt"); } public void testLongRange() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/longRange.kt"); } public void testForInSmartCastedToArray() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/forInSmartCastedToArray.kt"); } public void testConditionOfEmptyIf() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/conditionOfEmptyIf.kt"); } public void testFinallyOnEmptyReturn() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("controlStructures/finallyOnEmptyReturn.kt"); } public void testKt3087() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt3087.kt"); } public void testKt3203_1() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt3203_1.kt"); } public void testKt3203_2() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt3203_2.kt"); } public void testKt3273() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt3273.kt"); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/EnumGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/EnumGenTest.java index cbee3a1b598..bf1f59f1a58 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/EnumGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/EnumGenTest.java @@ -65,11 +65,11 @@ public class EnumGenTest extends CodegenTestCase { assertEquals(0xFF0000, rgbMethod.invoke(redValue)); } - public void testSimple() throws NoSuchFieldException, IllegalAccessException { + public void testSimple() { blackBoxFile("enum/simple.kt"); } - public void testSimpleEnumInPackage() throws NoSuchFieldException, IllegalAccessException { + public void testSimpleEnumInPackage() { blackBoxFile("enum/inPackage.kt"); } @@ -89,16 +89,15 @@ public class EnumGenTest extends CodegenTestCase { blackBoxFile("enum/ordinal.kt"); } - public void testValues() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + public void testValues() { blackBoxFile("enum/valueof.kt"); } - public void testInClassObj() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + public void testInClassObj() { blackBoxFile("enum/inclassobj.kt"); } - public void testAbstractMethod() - throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + public void testAbstractMethod() { blackBoxFile("enum/abstractmethod.kt"); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java b/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java index 4156ed0bf6e..0c9e8d0479f 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java @@ -21,13 +21,18 @@ import org.jetbrains.jet.ConfigurationKind; import java.lang.reflect.Method; public class ExtensionFunctionsTest extends CodegenTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + } + @Override protected String getPrefix() { return "extensionFunctions"; } public void testSimple() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); final Method foo = generateFunction("foo"); final Character c = (Character) foo.invoke(null); @@ -35,71 +40,52 @@ public class ExtensionFunctionsTest extends CodegenTestCase { } public void testWhenFail() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); -// System.out.println(generateToText()); Method foo = generateFunction("foo"); assertThrows(foo, Exception.class, null, new StringBuilder()); } - public void testVirtual() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testVirtual() { blackBoxFile("extensionFunctions/virtual.kt"); } - public void testShared() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testShared() { blackBoxFile("extensionFunctions/shared.kt"); -// System.out.println(generateToText()); } - public void testKt475() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt475() { blackBoxFile("regressions/kt475.kt"); } - public void testKtNested() throws Exception { - createEnvironmentWithFullJdk(); - blackBoxFile("extensionFunctions/nested.kt"); - } - - public void testKt865() throws Exception { - createEnvironmentWithFullJdk(); + public void testKt865() { blackBoxFile("regressions/kt865.kt"); } - public void testKtNested2() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKtNested2() { blackBoxFile("extensionFunctions/nested2.kt"); } - public void testKt606() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt606() { blackBoxFile("regressions/kt606.kt"); } - public void testKt1061() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1061() { blackBoxFile("regressions/kt1061.kt"); } - public void testKt1249() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1249() { blackBoxFile("regressions/kt1249.kt"); } - public void testKt1290() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1290() { blackBoxFile("regressions/kt1290.kt"); } - public void testKt1953() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1953() { blackBoxFile("regressions/kt1953.kt"); } - public void testKt1953Class() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1953Class() { blackBoxFile("regressions/kt1953_class.kt"); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/FullJdkCodegenTest.java b/compiler/tests/org/jetbrains/jet/codegen/FullJdkCodegenTest.java new file mode 100644 index 00000000000..e1767a525df --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/codegen/FullJdkCodegenTest.java @@ -0,0 +1,49 @@ +/* + * 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.codegen; + +public class FullJdkCodegenTest extends CodegenTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + createEnvironmentWithFullJdk(); + } + + public void testKt434() { + blackBoxFile("regressions/kt434.kt"); + } + + public void testSynchronized() { + blackBoxFile("controlStructures/sync.kt"); + } + + public void testIfInWhile() { + blackBoxFile("controlStructures/ifInWhile.kt"); + } + + public void testKt2423() { + blackBoxFile("regressions/kt2423.kt"); + } + + public void testKt2509() { + blackBoxFile("regressions/kt2509.kt"); + } + + public void testIntCountDownLatchExtension() { + blackBoxFile("extensionFunctions/intCountDownLatchExtension.kt"); + } +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java index 1d24054bde2..ad92d75d26c 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java @@ -29,39 +29,32 @@ public class FunctionGenTest extends CodegenTestCase { createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); } - public void testKt2716() throws Exception { + public void testKt2716() { blackBoxFile("regressions/kt2716.kt"); - // System.out.println(generateToText()); } - public void testDefaultArgs() throws Exception { + public void testDefaultArgs() { blackBoxFile("functions/defaultargs.kt"); - // System.out.println(generateToText()); } - public void testDefaultArgs1() throws Exception { + public void testDefaultArgs1() { blackBoxFile("functions/defaultargs1.kt"); - // System.out.println(generateToText()); } - public void testDefaultArgs2() throws Exception { + public void testDefaultArgs2() { blackBoxFile("functions/defaultargs2.kt"); - // System.out.println(generateToText()); } - public void testDefaultArgs3() throws Exception { + public void testDefaultArgs3() { blackBoxFile("functions/defaultargs3.kt"); - // System.out.println(generateToText()); } - public void testDefaultArgs4() throws Exception { + public void testDefaultArgs4() { blackBoxFile("functions/defaultargs4.kt"); - // System.out.println(generateToText()); } - public void testDefaultArgs5() throws Exception { + public void testDefaultArgs5() { blackBoxFile("functions/defaultargs5.kt"); - // System.out.println(generateToText()); } public void testDefaultArgs6() { @@ -72,14 +65,12 @@ public class FunctionGenTest extends CodegenTestCase { blackBoxFile("functions/defaultargs7.kt"); } - public void testNoThisNoClosure() throws Exception { + public void testNoThisNoClosure() { blackBoxFile("functions/nothisnoclosure.kt"); - // System.out.println(generateToText()); } public void testAnyEqualsNullable() throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any?) = x.equals(\"lala\")"); - // System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); @@ -87,7 +78,6 @@ public class FunctionGenTest extends CodegenTestCase { public void testNoRefToOuter() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException { loadText("class A() { fun f() : ()->String { val s = \"OK\"; return { -> s } } }"); - // System.out.println(generateToText()); Class foo = generateClass("A"); final Object obj = foo.newInstance(); final Method f = foo.getMethod("f"); @@ -100,7 +90,6 @@ public class FunctionGenTest extends CodegenTestCase { public void testAnyEquals() throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any) = x.equals(\"lala\")"); - // System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); @@ -124,14 +113,13 @@ public class FunctionGenTest extends CodegenTestCase { public void testKt1199() { blackBoxFile("regressions/kt1199.kt"); - //System.out.println(generateToText()); } - public void testFunction() throws InvocationTargetException, IllegalAccessException { + public void testFunction() { blackBoxFile("functions/functionExpression.kt"); } - public void testLocalFunction() throws InvocationTargetException, IllegalAccessException { + public void testLocalFunction() { blackBoxFile("functions/localFunction.kt"); } @@ -160,13 +148,11 @@ public class FunctionGenTest extends CodegenTestCase { } public void testK1649_1() { - loadFile("regressions/kt1649_1.kt"); - generateToText(); + blackBoxFile("regressions/kt1649_1.kt"); } public void testK1649_2() { - loadFile("regressions/kt1649_2.kt"); - generateToText(); + blackBoxFile("regressions/kt1649_2.kt"); } public void testKt1038() { diff --git a/compiler/tests/org/jetbrains/jet/codegen/LocalClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/LocalClassGenTest.java index e2bac5de35c..c119ac15ea3 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/LocalClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/LocalClassGenTest.java @@ -34,7 +34,7 @@ public class LocalClassGenTest extends CodegenTestCase { } public void testEnum() { - //blackBoxFile("localcls/enum.kt"); + blackBoxFile("localcls/enum.kt"); } public void testObject() { diff --git a/compiler/tests/org/jetbrains/jet/codegen/MultiFileGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/MultiFileGenTest.java index ef12348ed0c..d6964187a7d 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/MultiFileGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/MultiFileGenTest.java @@ -22,12 +22,11 @@ public class MultiFileGenTest extends CodegenTestCase { @Override protected void setUp() throws Exception { super.setUp(); - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL); + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); } public void testSimple() { blackBoxMultiFile("/multi/simple/box.kt", "/multi/simple/ok.kt"); - //System.out.println(generateToText()); } public void testInternalVisibility() { @@ -41,8 +40,4 @@ public class MultiFileGenTest extends CodegenTestCase { public void testSameNames() { blackBoxMultiFile("/multi/same/1/box.kt", "/multi/same/2/box.kt"); } - - public void testKt1515() { - blackBoxMultiFile("/multi/kt1515/thisPackage.kt", "/multi/kt1515/otherPackage.kt"); - } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 2412c3fc51a..f89b59ad45b 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -17,7 +17,6 @@ package org.jetbrains.jet.codegen; import jet.IntRange; -import org.jetbrains.jet.ConfigurationKind; import java.awt.*; import java.lang.reflect.InvocationTargetException; @@ -34,8 +33,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testPSVM() throws Exception { loadFile("PSVM.kt"); -// System.out.println(generateToText()); - final Method main = generateFunction(); Object[] args = new Object[] { new String[0] }; main.invoke(null, args); @@ -43,8 +40,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testReturnOne() throws Exception { loadText("fun f() : Int { return 42; }"); -// System.out.println(generateToText()); - final Method main = generateFunction(); final Object returnValue = main.invoke(null, new Object[0]); assertEquals(new Integer(42), returnValue); @@ -52,8 +47,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testReturnA() throws Exception { loadText("fun foo(a : Int) = a"); -// System.out.println(generateToText()); - final Method main = generateFunction(); final Object returnValue = main.invoke(null, 50); assertEquals(new Integer(50), returnValue); @@ -61,8 +54,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testLocalProperty() throws Exception { loadFile("localProperty.kt"); -// System.out.println(generateToText()); - final Method main = generateFunction(); final Object returnValue = main.invoke(null, 76); assertEquals(new Integer(50), returnValue); @@ -70,7 +61,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testCurrentTime() throws Exception { loadText("fun f() : Long { return System.currentTimeMillis(); }"); -// System.out.println(generateToText()); final Method main = generateFunction(); final long returnValue = (Long) main.invoke(null); assertIsCurrentTime(returnValue); @@ -78,7 +68,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testIdentityHashCode() throws Exception { loadText("fun f(o: Any) : Int { return System.identityHashCode(o); }"); -// System.out.println(generateToText()); final Method main = generateFunction(); Object o = new Object(); final int returnValue = (Integer) main.invoke(null, o); @@ -94,16 +83,12 @@ public class NamespaceGenTest extends CodegenTestCase { public void testHelloWorld() throws Exception { loadFile("helloWorld.kt"); - -// System.out.println(generateToText()); - generateFunction(); // assert that it can be verified } public void testAssign() throws Exception { loadFile("assign.kt"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(2, main.invoke(null)); } @@ -129,7 +114,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testBoxVariable() throws Exception { loadText("fun foo(): Int? { var x = 239; return x; }"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(239, main.invoke(null)); } @@ -186,14 +170,12 @@ public class NamespaceGenTest extends CodegenTestCase { public void testBottles2() throws Exception { loadFile("bottles2.kt"); -// System.out.println(generateToText()); final Method main = generateFunction(); main.invoke(null); // ensure no exception } public void testJavaConstructor() throws Exception { loadText("fun foo(): StringBuilder = StringBuilder()"); -// System.out.println(generateToText()); final Method main = generateFunction(); final Object result = main.invoke(null); assertTrue(result instanceof StringBuilder); @@ -208,7 +190,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testJavaEquals() throws Exception { loadText("fun foo(s1: String, s2: String) = s1 == s2"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(Boolean.TRUE, main.invoke(null, new String("jet"), new String("jet"))); assertEquals(Boolean.FALSE, main.invoke(null, new String("jet"), new String("ceylon"))); @@ -224,7 +205,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testJavaEqualsNull() throws Exception { loadText("fun foo(s1: String?, s2: String?) = s1 == s2"); final Method main = generateFunction(); -// System.out.println(generateToText()); assertEquals(Boolean.TRUE, main.invoke(null, null, null)); assertEquals(Boolean.FALSE, main.invoke(null, "jet", null)); assertEquals(Boolean.FALSE, main.invoke(null, null, "jet")); @@ -233,7 +213,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testEqualsNullLiteral() throws Exception { loadText("fun foo(s: String?) = s == null"); final Method main = generateFunction(); -// System.out.println(generateToText()); assertEquals(Boolean.TRUE, main.invoke(null, new Object[] { null })); assertEquals(Boolean.FALSE, main.invoke(null, "jet")); } @@ -258,7 +237,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFunctionCall() throws Exception { loadFile("functionCall.kt"); -// System.out.println(generateToText()); final Method main = generateFunction("f"); assertEquals("foo", main.invoke(null)); } @@ -280,14 +258,12 @@ public class NamespaceGenTest extends CodegenTestCase { public void testStringPlusEq() throws Exception { loadText("fun foo(s: String) : String { var result = s; result += s; return result; } "); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals("JarJar", main.invoke(null, "Jar")); } public void testStringCompare() throws Exception { loadText("fun foo(s1: String, s2: String) = s1 < s2"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(Boolean.TRUE, main.invoke(null, "Ceylon", "Java")); assertEquals(Boolean.FALSE, main.invoke(null, "Jet", "Java")); @@ -315,7 +291,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFieldRead() throws Exception { loadText("import java.awt.*; fun foo(c: GridBagConstraints) = c.gridx"); -// System.out.println(generateToText()); final Method main = generateFunction(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 239; @@ -332,7 +307,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFieldIncrement() throws Exception { loadText("import java.awt.*; fun foo(c: GridBagConstraints) { c.gridx++; return; }"); -// System.out.println(generateToText()); final Method main = generateFunction(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 609; @@ -342,7 +316,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFieldAugAssign() throws Exception { loadText("import java.awt.*; fun foo(c: GridBagConstraints) { c.gridx *= 2; return; }"); -// System.out.println(generateToText()); final Method main = generateFunction(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 305; @@ -371,7 +344,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayAugAssign() throws Exception { loadText("fun foo(c: Array) { c[0] *= 2 }"); -// System.out.println(generateToText()); final Method main = generateFunction(); Integer[] data = new Integer[] { 5 }; main.invoke(null, new Object[] { data }); @@ -380,7 +352,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayAugAssignLong() throws Exception { loadText("fun foo(c: LongArray) { c[0] *= 2.toLong() }"); -// System.out.println(generateToText()); final Method main = generateFunction(); long[] data = new long[] { 5 }; main.invoke(null, new Object[] { data }); @@ -389,7 +360,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayNew() throws Exception { loadText("fun foo() = Array(4, { it })"); -// System.out.println(generateToText()); final Method main = generateFunction(); Integer[] result = (Integer[]) main.invoke(null); assertEquals(4, result.length); @@ -401,14 +371,12 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayNewNullable() throws Exception { loadText("fun foo() = arrayOfNulls(4)"); -// System.out.println(generateToText()); final Method main = generateFunction(); Integer[] result = (Integer[]) main.invoke(null); assertEquals(4, result.length); } public void testFloatArrayNew() throws Exception { loadText("fun foo() = FloatArray(4)"); -// System.out.println(generateToText()); final Method main = generateFunction(); float[] result = (float[]) main.invoke(null); assertEquals(4, result.length); @@ -416,7 +384,6 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFloatArrayArrayNew() throws Exception { loadText("fun foo() = Array(4, { FloatArray(5-it) })"); -// System.out.println(generateToText()); final Method main = generateFunction(); float[][] result = (float[][]) main.invoke(null); assertEquals(4, result.length); @@ -425,17 +392,14 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArraySize() throws Exception { loadText("fun foo(a: Array) = a.size"); -// System.out.println(generateToText()); final Method main = generateFunction(); Object[] args = new Object[] { new Integer[4] }; int result = (Integer) main.invoke(null, args); - System.out.println(result); assertEquals(4, result); } public void testIntArraySize() throws Exception { loadText("fun foo(a: IntArray) = a.size"); -// System.out.println(generateToText()); final Method main = generateFunction(); Object[] args = new Object[] { new int[4] }; int result = (Integer) main.invoke(null, args); diff --git a/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java index e7ebb142723..6230cb75dc0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java @@ -27,17 +27,14 @@ public class ObjectGenTest extends CodegenTestCase { public void testSimpleObject() { blackBoxFile("objects/simpleObject.kt"); -// System.out.println(generateToText()); } public void testObjectLiteral() { blackBoxFile("objects/objectLiteral.kt"); -// System.out.println(generateToText()); } public void testObjectLiteralInClosure() { blackBoxFile("objects/objectLiteralInClosure.kt"); -// System.out.println(generateToText()); } public void testMethodOnObject() { diff --git a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java index d2e1d20ccb8..85b338a7006 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java @@ -21,7 +21,6 @@ import org.jetbrains.jet.ConfigurationKind; import java.lang.reflect.Method; public class PatternMatchingTest extends CodegenTestCase { - @Override protected void setUp() throws Exception { super.setUp(); @@ -56,7 +55,6 @@ public class PatternMatchingTest extends CodegenTestCase { public void testInrange() throws Exception { loadFile(); -// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("array list", foo.invoke(null, 239)); assertEquals("digit", foo.invoke(null, 0)); @@ -66,27 +64,24 @@ public class PatternMatchingTest extends CodegenTestCase { assertEquals("something", foo.invoke(null, 19)); } - public void testIs() throws Exception { - loadFile(); -// System.out.println(generateToText()); - blackBox(); + public void testIs() { + blackBoxFile("patternMatching/is.kt"); } - public void testRange() throws Exception { + public void testRange() { blackBoxFile("patternMatching/range.kt"); } - public void testLongInRange() throws Exception { + public void testLongInRange() { blackBoxFile("patternMatching/longInRange.kt"); } - public void testWhenArgumentIsEvaluatedOnlyOnce() throws Exception { + public void testWhenArgumentIsEvaluatedOnlyOnce() { blackBoxFile("patternMatching/whenArgumentIsEvaluatedOnlyOnce.kt"); } public void testRangeChar() throws Exception { loadFile(); -// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("digit", foo.invoke(null, '0')); assertEquals("something", foo.invoke(null, 'A')); @@ -111,7 +106,7 @@ public class PatternMatchingTest extends CodegenTestCase { assertEquals("something", foo.invoke(null, "C#")); } - public void testCallProperty() throws Exception { + public void testCallProperty() { blackBoxFile("patternMatching/callProperty.kt"); } @@ -123,19 +118,19 @@ public class PatternMatchingTest extends CodegenTestCase { assertEquals("something", foo.invoke(null, 2)); } - public void testNullableWhen() throws Exception { // KT-2148 + public void testNullableWhen() { blackBoxFile("patternMatching/nullableWhen.kt"); } - public void testKt2466() throws Exception { + public void testKt2466() { blackBoxFile("patternMatching/kt2466.kt"); } - public void testMatchNotNullAgainstNullable() throws Exception { + public void testMatchNotNullAgainstNullable() { blackBoxFile("patternMatching/matchNotNullAgainstNullable.kt"); } - public void testKt2457() throws Exception { + public void testKt2457() { blackBoxFile("regressions/kt2457.kt"); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index 989f692fe0d..1c6d66b517e 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -30,9 +30,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testPlus() throws Exception { loadText("fun f(a: Int, b: Int): Int { return a + b }"); - -// System.out.println(generateToText()); - final Method main = generateFunction(); final int returnValue = (Integer) main.invoke(null, 37, 5); assertEquals(42, returnValue); @@ -41,7 +38,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testGt() throws Exception { loadText("fun foo(f: Int): Boolean { if (f > 0) return true; return false; }"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(true, main.invoke(null, 1)); assertEquals(false, main.invoke(null, 0)); @@ -78,7 +74,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testLong() throws Exception { loadText("fun foo(a: Long, b: Long): Long = a + b"); -// System.out.println(generateToText()); final Method main = generateFunction(); long arg = (long) Integer.MAX_VALUE; long expected = 2 * (long) Integer.MAX_VALUE; @@ -87,7 +82,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testLongCmp() throws Exception { loadText("fun foo(a: Long, b: Long): Long = if (a == b) 0xffffffff else 0xfffffffe"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(0xffffffffL, main.invoke(null, 1, 1)); assertEquals(0xfffffffeL, main.invoke(null, 1, 0)); @@ -153,7 +147,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testDoubleToInt() throws Exception { loadText("fun foo(a: Double): Int = a.toInt()"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(1, main.invoke(null, 1.0)); } @@ -237,7 +230,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testBitInv() throws Exception { loadText("fun foo(a: Int): Int = a.inv()"); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(0xffff0000, main.invoke(null, 0x0000ffff)); } @@ -270,14 +262,12 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testDecrementAsStatement() throws Exception { loadFile("bottles.kt"); -// System.out.println(generateToText()); final Method main = generateFunction(); main.invoke(null); // ensure no exception } private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception { loadText(text); -// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(expected, main.invoke(null, arg1, arg2)); } @@ -370,7 +360,6 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testKt756 () { blackBoxFile("regressions/kt756.kt"); - //System.out.println(generateToText()); } public void testKt757 () { diff --git a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java index edcd064e8d2..85bda3d988b 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java @@ -22,13 +22,18 @@ import org.jetbrains.jet.ConfigurationKind; import java.lang.reflect.*; public class PropertyGenTest extends CodegenTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + } + @Override protected String getPrefix() { return "properties"; } public void testPrivateVal() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVal"); final Field[] fields = aClass.getDeclaredFields(); @@ -38,7 +43,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testPrivateVar() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVar"); final Object instance = aClass.newInstance(); @@ -49,7 +53,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testPublicVar() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("class PublicVar() { public var foo : Int = 0; }"); final Class aClass = loadImplementationClass(generateClassesInFile(), "PublicVar"); final Object instance = aClass.newInstance(); @@ -60,7 +63,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testAccessorsInInterface() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("class AccessorsInInterface() { public var foo : Int = 0; }"); final Class aClass = loadClass("AccessorsInInterface", generateClassesInFile()); assertNotNull(findMethodByName(aClass, "getFoo")); @@ -68,7 +70,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testPrivatePropertyInNamespace() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("private val x = 239"); final Class nsClass = generateNamespaceClass(); final Field[] fields = nsClass.getDeclaredFields(); @@ -81,35 +82,31 @@ public class PropertyGenTest extends CodegenTestCase { } public void testFieldPropertyAccess() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile("properties/fieldPropertyAccess.kt"); -// System.out.println(generateToText()); final Method method = generateFunction("increment"); assertEquals(1, method.invoke(null)); assertEquals(2, method.invoke(null)); } public void testFieldGetter() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("val now: Long get() = System.currentTimeMillis(); fun foo() = now"); final Method method = generateFunction("foo"); assertIsCurrentTime((Long) method.invoke(null)); } public void testFieldSetter() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); final Method method = generateFunction("append"); method.invoke(null, "IntelliJ "); String value = (String) method.invoke(null, "IDEA"); if (!value.equals("IntelliJ IDEA")) { System.out.println(generateToText()); + throw new AssertionError(value); } assertEquals("IntelliJ IDEA", value); } public void testFieldSetterPlusEq() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); final Method method = generateFunction("append"); method.invoke(null, "IntelliJ "); @@ -118,9 +115,7 @@ public class PropertyGenTest extends CodegenTestCase { } public void testAccessorsWithoutBody() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("class AccessorsWithoutBody() { protected var foo: Int = 349\n get\n private set\n fun setter() { foo = 610; } } "); -// System.out.println(generateToText()); final Class aClass = loadImplementationClass(generateClassesInFile(), "AccessorsWithoutBody"); final Object instance = aClass.newInstance(); final Method getFoo = findMethodByName(aClass, "getFoo"); @@ -136,7 +131,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testInitializersForNamespaceProperties() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("val x = System.currentTimeMillis()"); final Method method = generateFunction("getX"); method.setAccessible(true); @@ -144,7 +138,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testPropertyReceiverOnStack() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadFile(); final Class aClass = loadImplementationClass(generateClassesInFile(), "Evaluator"); final Constructor constructor = aClass.getConstructor(StringBuilder.class); @@ -156,7 +149,6 @@ public class PropertyGenTest extends CodegenTestCase { } public void testAbstractVal() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("abstract class Foo { public abstract val x: String }"); final ClassFileFactory codegens = generateClassesInFile(); final Class aClass = loadClass("Foo", codegens); @@ -164,77 +156,61 @@ public class PropertyGenTest extends CodegenTestCase { } public void testVolatileProperty() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("abstract class Foo { public volatile var x: String = \"\"; }"); -// System.out.println(generateToText()); final ClassFileFactory codegens = generateClassesInFile(); final Class aClass = loadClass("Foo", codegens); Field x = aClass.getDeclaredField("x"); assertTrue((x.getModifiers() & Modifier.VOLATILE) != 0); } - public void testKt257 () throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt257() { blackBoxFile("regressions/kt257.kt"); -// System.out.println(generateToText()); } - public void testKt613 () throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt613() { blackBoxFile("regressions/kt613.kt"); } public void testKt160() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); loadText("internal val s = java.lang.Double.toString(1.0)"); final Method method = generateFunction("getS"); method.setAccessible(true); assertEquals(method.invoke(null), "1.0"); } - public void testKt1165() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1165() { blackBoxFile("regressions/kt1165.kt"); } - public void testKt1168() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1168() { blackBoxFile("regressions/kt1168.kt"); } - public void testKt1170() throws Exception { - createEnvironmentWithFullJdk(); + public void testKt1170() { blackBoxFile("regressions/kt1170.kt"); } - public void testKt1159() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1159() { blackBoxFile("regressions/kt1159.kt"); } - public void testKt1417() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1417() { blackBoxFile("regressions/kt1417.kt"); } - public void testKt1398() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1398() { blackBoxFile("regressions/kt1398.kt"); } - public void testKt2331() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2331() { blackBoxFile("regressions/kt2331.kt"); } - public void testKt1892() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1892() { blackBoxFile("regressions/kt1892.kt"); - //System.out.println(generateToText()); } - public void testKt1846() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1846() { loadFile("regressions/kt1846.kt"); final Class aClass = loadImplementationClass(generateClassesInFile(), "A"); try { @@ -254,43 +230,31 @@ public class PropertyGenTest extends CodegenTestCase { } } - public void testKt1482_2279() throws Exception { - createEnvironmentWithFullJdk(); + public void testKt1482_2279() { blackBoxFile("regressions/kt1482_2279.kt"); } - public void testKt1714() throws Exception { - createEnvironmentWithFullJdk(); + public void testKt1714() { blackBoxFile("regressions/kt1714.kt"); } - public void testKt1714_minimal() throws Exception { - createEnvironmentWithFullJdk(); + public void testKt1714_minimal() { blackBoxFile("regressions/kt1714_minimal.kt"); } - public void testKt2509() throws Exception { - createEnvironmentWithFullJdk(); - blackBoxFile("regressions/kt2509.kt"); - } - - public void testKt2786() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2786() { blackBoxFile("regressions/kt2786.kt"); } - public void testKt2655() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2655() { blackBoxFile("regressions/kt2655.kt"); } - public void testKt1528() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt1528() { blackBoxMultiFile("regressions/kt1528_1.kt", "regressions/kt1528_3.kt"); } - public void testKt2589() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2589() { loadFile("regressions/kt2589.kt"); final Class aClass = loadImplementationClass(generateClassesInFile(), "Foo"); assertTrue((aClass.getModifiers() & Opcodes.ACC_FINAL) == 0); @@ -318,8 +282,7 @@ public class PropertyGenTest extends CodegenTestCase { } } - public void testKt2677() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2677() { loadFile("regressions/kt2677.kt"); final Class aClass = loadImplementationClass(generateClassesInFile(), "DerivedWeatherReport"); final Class bClass = aClass.getSuperclass(); @@ -358,23 +321,19 @@ public class PropertyGenTest extends CodegenTestCase { } } - public void testKt2892() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2892() { blackBoxFile("properties/kt2892.kt"); } - public void testAccessToPrivateProperty() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testAccessToPrivateProperty() { blackBoxFile("properties/accessToPrivateProperty.kt"); } - public void testAccessToPrivateSetter() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testAccessToPrivateSetter() { blackBoxFile("properties/accessToPrivateSetter.kt"); } - public void testKt2202() throws Exception { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testKt2202() { loadFile("properties/kt2202.kt"); String text = generateToText(); assertFalse(text.contains("INVOKEVIRTUAL")); diff --git a/compiler/tests/org/jetbrains/jet/codegen/SafeRefTest.java b/compiler/tests/org/jetbrains/jet/codegen/SafeRefTest.java index f25722d8842..a4edacd7c6c 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/SafeRefTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/SafeRefTest.java @@ -22,22 +22,22 @@ public class SafeRefTest extends CodegenTestCase { @Override protected void setUp() throws Exception { super.setUp(); - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS); + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); } - public void test247 () throws Exception { + public void test247() { blackBoxFile("regressions/kt247.kt"); } - public void test245 () throws Exception { + public void test245() { blackBoxFile("regressions/kt245.kt"); } - public void test232 () throws Exception { + public void test232() { blackBoxFile("regressions/kt232.kt"); } - public void test1572 () throws Exception { + public void test1572() { blackBoxFile("regressions/kt1572.kt"); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java index fcb226e7dc5..977cb0a12e2 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java @@ -96,7 +96,6 @@ public class StdlibTest extends CodegenTestCase { //from ClassGenTest public void testKt344 () throws Exception { loadFile("regressions/kt344.kt"); -// System.out.println(generateToText()); blackBox(); } @@ -339,7 +338,6 @@ public class StdlibTest extends CodegenTestCase { public void testKt2210() throws Exception { blackBoxFile("regressions/kt2210.kt"); -// System.out.println(generateToText()); } public void testKt2593() { @@ -369,4 +367,12 @@ public class StdlibTest extends CodegenTestCase { public void testNoClassObjectForJavaClass() throws Exception { blackBoxFileWithJava("stdlib/noClassObjectForJavaClass.kt"); } + + public void testKt1076() { + blackBoxFile("regressions/kt1076.kt"); + } + + public void testKt1515() { + blackBoxMultiFile("/multi/kt1515/thisPackage.kt", "/multi/kt1515/otherPackage.kt"); + } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java b/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java index 6df980e40d8..fbcf89f6d08 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java @@ -31,14 +31,12 @@ public class StringsTest extends CodegenTestCase { public void testAnyToString () throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any) = x.toString()"); -// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("something", foo.invoke(null, "something")); } public void testNullableAnyToString () throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any?) = x.toString()"); -// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("something", foo.invoke(null, "something")); assertEquals("null", foo.invoke(null, new Object[]{null})); @@ -49,7 +47,6 @@ public class StringsTest extends CodegenTestCase { loadText("fun foo(x: String?, y: Any?) = x + y"); String text = generateToText(); assertTrue(text.contains(".stringPlus")); -// System.out.println(text); Method foo = generateFunction(); assertEquals("something239", foo.invoke(null, "something", 239)); assertEquals("null239", foo.invoke(null, null, 239)); @@ -62,7 +59,6 @@ public class StringsTest extends CodegenTestCase { loadText("fun foo(x: String, y: Any?) = x + y + 120"); String text = generateToText(); assertFalse(text.contains(".stringPlus")); -// System.out.println(text); Method foo = generateFunction(); assertEquals("something239120", foo.invoke(null, "something", 239)); assertEquals("239null120", foo.invoke(null, "239", null)); diff --git a/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java index 8bf1ab881d9..6e146de4de8 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java @@ -24,7 +24,7 @@ public class SuperGenTest extends CodegenTestCase { @Override protected void setUp() throws Exception { super.setUp(); - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS); + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); } public void testBasicProperty () { diff --git a/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java b/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java index a33df3f0f78..e2ec64ad1f6 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java @@ -33,12 +33,10 @@ public class TraitsTest extends CodegenTestCase { public void testSimple () { blackBoxFile("traits/simple.kt"); -// System.out.println(generateToText()); } public void testWithRequired () { blackBoxFile("traits/withRequired.kt"); -// System.out.println(generateToText()); } public void testMultiple () { diff --git a/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java index f5025677477..a4fbcc4ebbd 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java @@ -23,6 +23,5 @@ public class TupleGenTest extends CodegenTestCase { public void testUnitValue() { createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("/tuples/UnitValue.kt"); -// System.out.println(generateToText()); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java b/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java index 27117d3cb74..9f59500619f 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java @@ -21,7 +21,6 @@ import org.jetbrains.jet.ConfigurationKind; import java.lang.reflect.Method; public class TypeInfoTest extends CodegenTestCase { - @Override protected void setUp() throws Exception { super.setUp(); diff --git a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java index 26aa7b2c374..5e4d43be2fb 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java @@ -23,37 +23,35 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class VarArgTest extends CodegenTestCase { - public void testStringArray () throws InvocationTargetException, IllegalAccessException { + @Override + protected void setUp() throws Exception { + super.setUp(); createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + } + + public void testStringArray() throws InvocationTargetException, IllegalAccessException { loadText("fun test(vararg ts: String) = ts"); -// System.out.println(generateToText()); final Method main = generateFunction(); String[] args = {"mama", "papa"}; assertTrue(args == main.invoke(null, new Object[]{ args } )); } - public void testIntArray () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testIntArray() throws InvocationTargetException, IllegalAccessException { loadText("fun test(vararg ts: Int) = ts"); -// System.out.println(generateToText()); final Method main = generateFunction(); int[] args = {3, 4}; assertTrue(args == main.invoke(null, new Object[]{ args })); } - public void testIntArrayKotlinNoArgs () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testIntArrayKotlinNoArgs() throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(); fun testf(vararg ts: Int) = ts"); -// System.out.println(generateToText()); final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((int[])res).length == 0); } - public void testIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testIntArrayKotlin() throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(239, 7); fun testf(vararg ts: Int) = ts"); -// System.out.println(generateToText()); final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((int[])res).length == 2); @@ -61,10 +59,8 @@ public class VarArgTest extends CodegenTestCase { assertTrue(((int[])res)[1] == 7); } - public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testNullableIntArrayKotlin() throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(239.toByte(), 7.toByte()); fun testf(vararg ts: Byte?) = ts"); -// System.out.println(generateToText()); final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((Byte[])res).length == 2); @@ -72,20 +68,16 @@ public class VarArgTest extends CodegenTestCase { assertTrue(((Byte[])res)[1] == 7); } - public void testIntArrayKotlinObj () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testIntArrayKotlinObj() throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(\"239\"); fun testf(vararg ts: String) = ts"); -// System.out.println(generateToText()); final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((String[])res).length == 1); assertTrue(((String[])res)[0].equals("239")); } - public void testArrayT () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testArrayT() throws InvocationTargetException, IllegalAccessException { loadText("fun test() = _array(2, 4); fun _array(vararg elements : T) = elements"); -// System.out.println(generateToText()); final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((Integer[])res).length == 2); @@ -94,28 +86,22 @@ public class VarArgTest extends CodegenTestCase { } public void testKt581() { - createEnvironmentWithFullJdk(); blackBoxFile("regressions/kt581.kt"); } public void testKt797() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt796_797.kt"); } - public void testArrayAsVararg () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testArrayAsVararg() throws InvocationTargetException, IllegalAccessException { loadText("private fun asList(vararg elems: String) = elems; fun test(ts: Array) = asList(*ts); "); - //System.out.println(generateToText()); final Method main = generateFunction("test"); String[] args = {"mama", "papa"}; assertTrue(args == main.invoke(null, new Object[]{ args } )); } - public void testArrayAsVararg2 () throws InvocationTargetException, IllegalAccessException { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + public void testArrayAsVararg2() throws InvocationTargetException, IllegalAccessException { loadText("private fun asList(vararg elems: String) = elems; fun test(ts1: Array, ts2: String) = asList(*ts1, ts2); "); - //System.out.println(generateToText()); final Method main = generateFunction("test"); Object invoke = main.invoke(null, new Object[] {new String[] {"mama"}, "papa" }); assertInstanceOf(invoke, String[].class); @@ -125,7 +111,6 @@ public class VarArgTest extends CodegenTestCase { } public void testKt1978() { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("regressions/kt1978.kt"); } }