Reformat and cleanup most JVM codegen test classes
This commit is contained in:
@@ -34,56 +34,56 @@ public class VarArgTest extends CodegenTestCase {
|
||||
loadText("fun test(vararg ts: String) = ts");
|
||||
Method main = generateFunction();
|
||||
String[] args = {"mama", "papa"};
|
||||
assertTrue(args == main.invoke(null, new Object[]{ args } ));
|
||||
assertSame(args, main.invoke(null, new Object[] {args}));
|
||||
}
|
||||
|
||||
public void testIntArray() throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test(vararg ts: Int) = ts");
|
||||
Method main = generateFunction();
|
||||
int[] args = {3, 4};
|
||||
assertTrue(args == main.invoke(null, new Object[]{ args }));
|
||||
assertSame(args, main.invoke(null, new Object[] {args}));
|
||||
}
|
||||
|
||||
public void testIntArrayKotlinNoArgs() throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = testf(); fun testf(vararg ts: Int) = ts");
|
||||
Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((int[])res).length == 0);
|
||||
assertEquals(0, ((int[]) res).length);
|
||||
}
|
||||
|
||||
public void testIntArrayKotlin() throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = testf(239, 7); fun testf(vararg ts: Int) = ts");
|
||||
Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((int[])res).length == 2);
|
||||
assertTrue(((int[])res)[0] == 239);
|
||||
assertTrue(((int[])res)[1] == 7);
|
||||
assertEquals(2, ((int[]) res).length);
|
||||
assertEquals(239, ((int[]) res)[0]);
|
||||
assertEquals(7, ((int[]) res)[1]);
|
||||
}
|
||||
|
||||
public void testNullableIntArrayKotlin() throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = testf(239.toByte(), 7.toByte()); fun testf(vararg ts: Byte?) = ts");
|
||||
Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((Byte[])res).length == 2);
|
||||
assertTrue(((Byte[])res)[0] == (byte)239);
|
||||
assertTrue(((Byte[])res)[1] == 7);
|
||||
assertEquals(2, ((Byte[]) res).length);
|
||||
assertEquals((byte) ((Byte[]) res)[0], (byte) 239);
|
||||
assertEquals(7, (byte) ((Byte[]) res)[1]);
|
||||
}
|
||||
|
||||
public void testIntArrayKotlinObj() throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = testf(\"239\"); fun testf(vararg ts: String) = ts");
|
||||
Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((String[])res).length == 1);
|
||||
assertTrue(((String[])res)[0].equals("239"));
|
||||
assertEquals(1, ((String[]) res).length);
|
||||
assertEquals("239", ((String[]) res)[0]);
|
||||
}
|
||||
|
||||
public void testArrayT() throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = _array(2, 4); fun <T> _array(vararg elements : T) = elements");
|
||||
Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((Integer[])res).length == 2);
|
||||
assertTrue(((Integer[])res)[0].equals(2));
|
||||
assertTrue(((Integer[])res)[1].equals(4));
|
||||
assertEquals(2, ((Integer[]) res).length);
|
||||
assertEquals(2, (int) ((Integer[]) res)[0]);
|
||||
assertEquals(4, (int) ((Integer[]) res)[1]);
|
||||
}
|
||||
|
||||
public void testArrayAsVararg() throws InvocationTargetException, IllegalAccessException {
|
||||
@@ -91,7 +91,7 @@ public class VarArgTest extends CodegenTestCase {
|
||||
Method main = generateFunction("test");
|
||||
String[] args = {"mama", "papa"};
|
||||
String[] result = (String []) main.invoke(null, new Object[] {args});
|
||||
assertTrue(args != result);
|
||||
assertNotSame(args, result);
|
||||
assertTrue(Arrays.equals(args, result));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user