try to fix VarArgTest
Accoring to spec array of class.getMethods() is not sorted, so we can't just call getMethods()[0] to get desired method.
This commit is contained in:
@@ -26,7 +26,7 @@ public class VarArgTest extends CodegenTestCase {
|
||||
public void testIntArrayKotlinNoArgs () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = testf(); fun testf(vararg ts: Int) = ts");
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
final Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((int[])res).length == 0);
|
||||
}
|
||||
@@ -34,8 +34,7 @@ public class VarArgTest extends CodegenTestCase {
|
||||
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();
|
||||
System.out.println(main.toString());
|
||||
final Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((int[])res).length == 2);
|
||||
assertTrue(((int[])res)[0] == 239);
|
||||
@@ -45,7 +44,7 @@ public class VarArgTest extends CodegenTestCase {
|
||||
public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun test() = testf(239.byt, 7.byt); fun testf(vararg ts: Byte?) = ts");
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
final Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((Byte[])res).length == 2);
|
||||
assertTrue(((Byte[])res)[0] == (byte)239);
|
||||
@@ -55,7 +54,7 @@ public class VarArgTest extends CodegenTestCase {
|
||||
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();
|
||||
final Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((String[])res).length == 1);
|
||||
assertTrue(((String[])res)[0].equals("239"));
|
||||
@@ -64,7 +63,7 @@ public class VarArgTest extends CodegenTestCase {
|
||||
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();
|
||||
final Method main = generateFunction("test");
|
||||
Object res = main.invoke(null);
|
||||
assertTrue(((Integer[])res).length == 2);
|
||||
assertTrue(((Integer[])res)[0].equals(2));
|
||||
|
||||
Reference in New Issue
Block a user