Refactor codegen tests

- initialize environment only once in setUp()
- add comments on why some tests are disabled
- modify and rename some tests
- re-enable now working tests
- extract some tests into files with box()
- remove useless 'throws' declarations and commented code
This commit is contained in:
Alexander Udalov
2013-01-22 22:22:53 +04:00
committed by Alexander Udalov
parent 99827d10a8
commit 0df71bd696
76 changed files with 601 additions and 704 deletions
@@ -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
@@ -0,0 +1,11 @@
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
this[index1 + index2] = elem
}
fun box(): String {
val s = Array<String>(1, { "" })
s[1, -1] = "O"
s[2, -2] += "K"
return s[-3, 3]
}
@@ -0,0 +1,11 @@
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
this[index1 + index2] = elem
}
fun box(): String {
val s = Array<String>(1, { "" })
s[1, -1] = "OK"
return s[-2, 2]
}
@@ -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]}"
}
@@ -0,0 +1,14 @@
import java.util.ArrayList
fun ArrayList<String>.get(index1: Int, index2: Int) = this[index1 + index2]
fun ArrayList<String>.set(index1: Int, index2: Int, elem: String) {
this[index1 + index2] = elem
}
fun box(): String {
val s = ArrayList<String>(1)
s.add("")
s[1, -1] = "O"
s[2, -2] += "K"
return s[2, -2]
}
@@ -0,0 +1,13 @@
import java.util.ArrayList
fun ArrayList<String>.get(index1: Int, index2: Int) = this[index1 + index2]
fun ArrayList<String>.set(index1: Int, index2: Int, elem: String) {
this[index1 + index2] = elem
}
fun box(): String {
val s = ArrayList<String>(1)
s.add("")
s[1, -1] = "OK"
return s[2, -2]
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in BooleanArray(5)) {
if (x != false) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in ByteArray(5)) {
if (x != 0.toByte()) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in CharArray(5)) {
if (x != 0.toChar()) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in DoubleArray(5)) {
if (x != 0.toDouble()) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in FloatArray(5)) {
if (x != 0.toFloat()) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in IntArray(5)) {
if (x != 0) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in LongArray(5)) {
if (x != 0.toLong()) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,6 @@
fun box(): String {
for (x in ShortArray(5)) {
if (x != 0.toShort()) return "Fail $x"
}
return "OK"
}
@@ -0,0 +1,11 @@
import java.util.HashMap
fun HashMap<String, Int?>.set(index: String, elem: Int?) {
this.put(index, elem)
}
fun box(): String {
val s = HashMap<String, Int?>()
s["239"] = 239
return if (s["239"] == 239) "OK" else "Fail"
}
@@ -0,0 +1,9 @@
fun box(): String {
val a = Array<Int>(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"
}
@@ -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"
}
@@ -0,0 +1,9 @@
fun box(): String {
val x = Array<Int>(5, { it } ).iterator()
var i = 0
while (x.hasNext()) {
if (x.next() != i) return "Fail $i"
i++
}
return "OK"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -1,5 +1,3 @@
import java.lang.Integer
open class C {
open fun f(): Any = "C f"
}
@@ -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<String>) {
X().test()
}
}
@@ -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<String>) {
X().test()
}
}
@@ -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<String>) {
X().test()
}
}
@@ -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"
@@ -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
@@ -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"
}
}
@@ -4,7 +4,6 @@ class C() {
fun testReceiver() : String {
val res : String = "mama".toMyPrefixedString("111", "222")
System.out?.println(res)
return res
}
@@ -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--)
}
@@ -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"
@@ -1,3 +1,6 @@
// KT-2148
fun f(p: Int?): Int {
return when(p) {
null -> 3
@@ -6,4 +6,13 @@ fun test(a : A) {
if (a.method != null) {
a.method!!()
}
}
}
class B : A {
override val method = { }
}
fun box(): String {
test(B())
return "OK"
}
@@ -6,4 +6,13 @@ fun test(a : A) {
if (a.method != null) {
a.method!!()
}
}
}
class B : A {
override val method = { }
}
fun box(): String {
test(B())
return "OK"
}
@@ -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 {
@@ -1,6 +1,6 @@
import java.util.LinkedList
import java.util.ArrayList
open class BaseStringList: LinkedList<String>() {
open class BaseStringList: ArrayList<String>() {
}
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<String>).get(0) != "StringList.get()") return "Fail #3"
if ((myStringList: ArrayList<String>).get(0) != "StringList.get()") return "Fail #3"
return "OK"
}
+14 -12
View File
@@ -1,7 +1,5 @@
package test
class List<T>(len: Int, cls : java.lang.Class) {
val a : Array<T?> = Array<T?>(len)
class List<T>(len: Int) {
val a = Array<T?>(len) { null }
fun reverse() {
var i = 0
@@ -17,19 +15,19 @@ class List<T>(len: Int, cls : java.lang.Class) {
fun box() : String {
val d = List<Int>(1)
d.a[0] = 10
println(d.a[0])
checkEquals(d.a[0], 10)
val a = List<String>(1)
a.a[0] = "1"
println(a.a[0])
checkEquals(a.a[0], "1")
val b = List<Int?>(1)
b.a[0] = 10
println(b.a[0])
checkEquals(b.a[0], 10)
val c = List<Array<Int>>(1)
c.a[0] = Array<Int>(4,{-1})
println(c.a[0]?.size)
checkEquals(c.a[0]?.size, 4)
val e = List<Int>(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<String>) {
println(box())
}
@@ -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"
}
@@ -1,7 +1,7 @@
import java.util.*
class Template() {
val collected = LinkedList<String>()
val collected = ArrayList<String>()
fun String.plus() {
collected.add(this@plus)
@@ -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";
}
}
@@ -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";
}
}
@@ -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));
@@ -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<Array<String>> (5, { Array<String>(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<T>() { val a = Array<T?>(5) } fun foo() = L<Int>.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<T>() { val a = Array<T?>(5) { null } } fun foo() = L<Int>().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<T>(var a : T) {} fun foo() = L<Int>(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<Int>(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<Int>(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<String>(1); s.add(\"\"); s [1, -1] = \"5\"; s[2, -2] += \"7\"; return s[2,-2] }\n" +
"fun ArrayList<String>.get(index1: Int, index2 : Int) = this[index1+index2]!!\n" +
"fun ArrayList<String>.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<String>(1,{ \"\" }); s [1, -1] = \"5\"; s[2, -2] += \"7\"; return s[-3,3] }\n" +
"fun Array<String>.get(index1: Int, index2 : Int) = this[index1+index2]\n" +
"fun Array<String>.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<String>(1); s.add(\"\"); s [1, -1] = \"5\"; return s[2, -2] }\n" +
"fun ArrayList<String>.get(index1: Int, index2 : Int) = this[index1+index2]!!\n" +
"fun ArrayList<String>.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<String>(1,{ \"\" }); s [1, -1] = \"5\"; return s[-2, 2] }\n" +
"fun Array<String>.get(index1: Int, index2 : Int) = this[index1+index2]\n" +
"fun Array<String>.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<String,Int?>(); s[\"239\"] = 239; return s[\"239\"] }\n" +
"fun java.util.HashMap<String,Int?>.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");
}
}
@@ -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");
}
}
@@ -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");
}
@@ -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<String> 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<String> 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");
}
}
@@ -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");
}
@@ -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");
}
}
@@ -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");
}
}
@@ -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() {
@@ -34,7 +34,7 @@ public class LocalClassGenTest extends CodegenTestCase {
}
public void testEnum() {
//blackBoxFile("localcls/enum.kt");
blackBoxFile("localcls/enum.kt");
}
public void testObject() {
@@ -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");
}
}
@@ -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<Int>) { 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<Int>(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<Int>(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<FloatArray>(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<Int>) = 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);
@@ -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() {
@@ -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");
}
}
@@ -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 () {
@@ -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"));
@@ -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");
}
}
@@ -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");
}
}
@@ -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));
@@ -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 () {
@@ -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 () {
@@ -23,6 +23,5 @@ public class TupleGenTest extends CodegenTestCase {
public void testUnitValue() {
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
blackBoxFile("/tuples/UnitValue.kt");
// System.out.println(generateToText());
}
}
@@ -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();
@@ -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 <T> _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<String>) = 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<String>, 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");
}
}