Merge branch 'master' of ssh://git.labs.intellij.net/jet
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fun box() : String {
|
||||
val a = Array<Int> (5)
|
||||
val a = Array<Int> (5, {0})
|
||||
var i = 0
|
||||
var sum = 0
|
||||
for(el in 0..4) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
fun box() : String {
|
||||
val a = IntArray (5)
|
||||
var i = 0
|
||||
var sum = 0
|
||||
for(el in 0..4) {
|
||||
a[i] = i++
|
||||
}
|
||||
for (el in a) {
|
||||
sum = sum + el
|
||||
}
|
||||
if(sum != 10) return "a failed"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -44,7 +44,7 @@ fun box() : String {
|
||||
}
|
||||
if(sum != 15) return "c4 failed"
|
||||
|
||||
val a : Array<Int> = Array<Int> (5)
|
||||
val a : Array<Int> = Array<Int> (5, {0})
|
||||
for(el in 0..4) {
|
||||
a[i] = i++
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fun main(args: Array<String>?) {
|
||||
//do not compile
|
||||
System.out?.println(fff<Unit>(())) //do not compile
|
||||
System.out?.println(id<Unit>(y)) //do not compile
|
||||
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0),{(e : Int) : Unit => }))) //do not compile
|
||||
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit => }))) //do not compile
|
||||
}
|
||||
class A<T>()
|
||||
|
||||
@@ -30,7 +30,7 @@ fun almostFilter(array: Array<Int>, action: fun(Int): Int) {
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val a = Array<Int> (3)
|
||||
val a = Array<Int> (3,{-1})
|
||||
a[0] = 0
|
||||
a[1] = 1
|
||||
a[2] = 2
|
||||
|
||||
@@ -5,7 +5,7 @@ fun t1 () {
|
||||
}
|
||||
|
||||
fun t2 () {
|
||||
val a2 = Array<Int>(1)
|
||||
val a2 = Array<Int>(1,{0})
|
||||
a2[0] = 0 //ok
|
||||
var i = a2[0] //ok
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ fun box() : String {
|
||||
println(b.a[0])
|
||||
|
||||
val c = List<Array<Int>>(1)
|
||||
c.a[0] = Array<Int>(4)
|
||||
c.a[0] = Array<Int>(4,{-1})
|
||||
println(c.a[0].size)
|
||||
|
||||
val e = List<Int>(5)
|
||||
|
||||
@@ -17,15 +17,24 @@ public class ArrayGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testCreateMultiInt () throws Exception {
|
||||
loadText("fun foo() = Array<Array<Int>> (5)");
|
||||
loadText("fun foo() = Array<Array<Int>> (5, { Array<Int>(it, {239}) })");
|
||||
Method foo = generateFunction();
|
||||
Object invoke = foo.invoke(null);
|
||||
System.out.println(invoke.getClass());
|
||||
assertTrue(invoke instanceof Integer[][]);
|
||||
Integer[][] invoke = (Integer[][]) foo.invoke(null);
|
||||
assertEquals(invoke[2].length, 2);
|
||||
assertEquals(invoke[4].length, 4);
|
||||
assertEquals(invoke[4][2].intValue(), 239);
|
||||
}
|
||||
|
||||
public void testCreateMultiIntNullable () throws Exception {
|
||||
loadText("fun foo() = Array<Array<Int?>> (5, { Array<Int?>(it) })");
|
||||
Method foo = generateFunction();
|
||||
Integer[][] invoke = (Integer[][]) foo.invoke(null);
|
||||
assertEquals(invoke[2].length, 2);
|
||||
assertEquals(invoke[4].length, 4);
|
||||
}
|
||||
|
||||
public void testCreateMultiString () throws Exception {
|
||||
loadText("fun foo() = Array<Array<String>> (5)");
|
||||
loadText("fun foo() = Array<Array<String>> (5, { Array<String>(0,{\"\"}) })");
|
||||
Method foo = generateFunction();
|
||||
Object invoke = foo.invoke(null);
|
||||
System.out.println(invoke.getClass());
|
||||
|
||||
@@ -151,6 +151,10 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
blackBoxFile("controlStructures/forIntArray.jet");
|
||||
}
|
||||
|
||||
public void testForPrimitiveIntArray() throws Exception {
|
||||
blackBoxFile("controlStructures/forPrimitiveIntArray.jet");
|
||||
}
|
||||
|
||||
public void testForNullableIntArray() throws Exception {
|
||||
blackBoxFile("controlStructures/forNullableIntArray.jet");
|
||||
}
|
||||
|
||||
@@ -374,13 +374,24 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testArrayNew() throws Exception {
|
||||
loadText("fun foo() = Array<Int>(4)");
|
||||
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);
|
||||
assertEquals(0, result[0].intValue());
|
||||
assertEquals(1, result[1].intValue());
|
||||
assertEquals(2, result[2].intValue());
|
||||
assertEquals(3, result[3].intValue());
|
||||
}
|
||||
|
||||
public void testArrayNewNullable() throws Exception {
|
||||
loadText("fun foo() = Array<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());
|
||||
@@ -390,11 +401,12 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testFloatArrayArrayNew() throws Exception {
|
||||
loadText("fun foo() = Array<FloatArray>(4)");
|
||||
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);
|
||||
assertEquals(2, result[3].length);
|
||||
}
|
||||
|
||||
public void testArraySize() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user