array codegen bugs

This commit is contained in:
Alex Tkachman
2011-09-28 10:54:45 +03:00
parent a06aa17a5f
commit 8a927d70d7
9 changed files with 120 additions and 17 deletions
@@ -0,0 +1,25 @@
namespace test
class List<T>() {
val a : Array<T> = Array<T>(1)
}
fun box() : String {
val a = List<String>()
a.a[0] = "1"
println(a.a[0])
val b = List<Int?>()
b.a[0] = 10
println(b.a[0])
val c = List<Array<Int>>()
c.a[0] = Array<Int>(4)
println(c.a[0].size)
return "OK"
}
fun println(s : Any?) {
System.out?.println(s);
}
@@ -0,0 +1,49 @@
package org.jetbrains.jet.codegen;
import java.lang.reflect.Method;
public class ArrayGenTest extends CodegenTestCase {
public void testKt238 () throws Exception {
blackBoxFile("regressions/kt238.jet");
}
public void testKt326 () throws Exception {
blackBoxFile("regressions/kt326.jet");
}
public void testCreateMultiInt () throws Exception {
loadText("fun foo() = Array<Array<Int>> (5)");
Method foo = generateFunction();
Object invoke = foo.invoke(null);
System.out.println(invoke.getClass());
assertTrue(invoke instanceof int[][]);
}
public void testCreateMultiString () throws Exception {
loadText("fun foo() = Array<Array<String>> (5)");
Method foo = generateFunction();
Object invoke = foo.invoke(null);
System.out.println(invoke.getClass());
assertTrue(invoke instanceof String[][]);
}
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 instanceof Integer[]);
*/
}
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);
}
}
@@ -1,7 +0,0 @@
package org.jetbrains.jet.codegen;
public class ArrayGenTestCase extends CodegenTestCase {
public void testKt238 () throws Exception {
blackBoxFile("regressions/kt238.jet");
}
}