some debug print commented out
This commit is contained in:
@@ -17,8 +17,7 @@ import java.util.Arrays;
|
||||
public class NamespaceGenTest extends CodegenTestCase {
|
||||
public void testPSVM() throws Exception {
|
||||
loadFile("PSVM.jet");
|
||||
final String text = generateToText();
|
||||
System.out.println(text);
|
||||
// System.out.println(generateToText());
|
||||
|
||||
final Method main = generateFunction();
|
||||
Object[] args = new Object[] { new String[0] };
|
||||
@@ -27,8 +26,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testReturnOne() throws Exception {
|
||||
loadText("fun f() : Int { return 42; }");
|
||||
final String text = generateToText();
|
||||
System.out.println(text);
|
||||
// System.out.println(generateToText());
|
||||
|
||||
final Method main = generateFunction();
|
||||
final Object returnValue = main.invoke(null, new Object[0]);
|
||||
@@ -37,8 +35,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testReturnA() throws Exception {
|
||||
loadText("fun foo(a : Int) = a");
|
||||
final String text = generateToText();
|
||||
System.out.println(text);
|
||||
// System.out.println(generateToText());
|
||||
|
||||
final Method main = generateFunction();
|
||||
final Object returnValue = main.invoke(null, 50);
|
||||
@@ -47,8 +44,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testLocalProperty() throws Exception {
|
||||
loadFile("localProperty.jet");
|
||||
final String text = generateToText();
|
||||
System.out.println(text);
|
||||
// System.out.println(generateToText());
|
||||
|
||||
final Method main = generateFunction();
|
||||
final Object returnValue = main.invoke(null, 76);
|
||||
@@ -57,7 +53,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testCurrentTime() throws Exception {
|
||||
loadText("fun f() : Long { return System.currentTimeMillis(); }");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
final long returnValue = (Long) main.invoke(null);
|
||||
assertIsCurrentTime(returnValue);
|
||||
@@ -65,7 +61,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testIdentityHashCode() throws Exception {
|
||||
loadText("fun f(o: Any) : Int { return System.identityHashCode(o); }");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Object o = new Object();
|
||||
final int returnValue = (Integer) main.invoke(null, o);
|
||||
@@ -82,7 +78,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
public void testHelloWorld() throws Exception {
|
||||
loadFile("helloWorld.jet");
|
||||
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
|
||||
generateFunction(); // assert that it can be verified
|
||||
}
|
||||
@@ -90,7 +86,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
public void testAssign() throws Exception {
|
||||
loadFile("assign.jet");
|
||||
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
assertEquals(2, main.invoke(null));
|
||||
}
|
||||
@@ -116,7 +112,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testBoxVariable() throws Exception {
|
||||
loadText("fun foo(): Int? { var x = 239; return x; }");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
assertEquals(239, main.invoke(null));
|
||||
}
|
||||
@@ -173,14 +169,14 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testBottles2() throws Exception {
|
||||
loadFile("bottles2.jet");
|
||||
System.out.println(generateToText());
|
||||
// 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());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
final Object result = main.invoke(null);
|
||||
assertTrue(result instanceof StringBuilder);
|
||||
@@ -195,7 +191,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testJavaEquals() throws Exception {
|
||||
loadText("fun foo(s1: String, s2: String) = s1 == s2");
|
||||
System.out.println(generateToText());
|
||||
// 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")));
|
||||
@@ -211,7 +207,7 @@ 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());
|
||||
// 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"));
|
||||
@@ -220,7 +216,7 @@ 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());
|
||||
// System.out.println(generateToText());
|
||||
assertEquals(Boolean.TRUE, main.invoke(null, new Object[] { null }));
|
||||
assertEquals(Boolean.FALSE, main.invoke(null, "jet"));
|
||||
}
|
||||
@@ -245,7 +241,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testFunctionCall() throws Exception {
|
||||
loadFile("functionCall.jet");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction("f");
|
||||
assertEquals("foo", main.invoke(null));
|
||||
}
|
||||
@@ -267,14 +263,14 @@ 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());
|
||||
// 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());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
assertEquals(Boolean.TRUE, main.invoke(null, "Ceylon", "Java"));
|
||||
assertEquals(Boolean.FALSE, main.invoke(null, "Jet", "Java"));
|
||||
@@ -302,7 +298,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testFieldRead() throws Exception {
|
||||
loadText("import java.awt.*; fun foo(c: GridBagConstraints) = c.gridx");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 239;
|
||||
@@ -319,7 +315,7 @@ 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());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 609;
|
||||
@@ -329,7 +325,7 @@ 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());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 305;
|
||||
@@ -358,7 +354,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testArrayAugAssign() throws Exception {
|
||||
loadText("fun foo(c: Array<Int>) { c[0] *= 2 }");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Integer[] data = new Integer[] { 5 };
|
||||
main.invoke(null, new Object[] { data });
|
||||
@@ -367,7 +363,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testArrayAugAssignLong() throws Exception {
|
||||
loadText("fun foo(c: LongArray) { c[0] *= 2.lng }");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
long[] data = new long[] { 5 };
|
||||
main.invoke(null, new Object[] { data });
|
||||
@@ -376,7 +372,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testArrayNew() throws Exception {
|
||||
loadText("fun foo() = Array<Int>(4, { it })");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Integer[] result = (Integer[]) main.invoke(null);
|
||||
assertEquals(4, result.length);
|
||||
@@ -388,14 +384,14 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testArrayNewNullable() throws Exception {
|
||||
loadText("fun foo() = Array<Int?>(4)");
|
||||
System.out.println(generateToText());
|
||||
// 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());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
float[] result = (float[]) main.invoke(null);
|
||||
assertEquals(4, result.length);
|
||||
@@ -403,7 +399,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testFloatArrayArrayNew() throws Exception {
|
||||
loadText("fun foo() = Array<FloatArray>(4, { FloatArray(5-it) })");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
float[][] result = (float[][]) main.invoke(null);
|
||||
assertEquals(4, result.length);
|
||||
@@ -412,7 +408,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testArraySize() throws Exception {
|
||||
loadText("fun foo(a: Array<Int>) = a.size");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Object[] args = new Object[] { new Integer[4] };
|
||||
int result = (Integer) main.invoke(null, args);
|
||||
@@ -422,7 +418,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testIntArraySize() throws Exception {
|
||||
loadText("fun foo(a: IntArray) = a.size");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Object[] args = new Object[] { new int[4] };
|
||||
int result = (Integer) main.invoke(null, args);
|
||||
@@ -490,7 +486,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testTupleLiteral() throws Exception {
|
||||
loadText("fun foo() = (1, \"foo\")");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Tuple2 tuple2 = (Tuple2) main.invoke(null);
|
||||
assertEquals(1, tuple2._1);
|
||||
@@ -499,7 +495,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testParametrizedTupleLiteral() throws Exception {
|
||||
loadText("fun <E,D> E.foo(extra: java.util.List<D>) = (1, \"foo\", this, extra)");
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", TypeInfo.STRING_TYPE_INFO, TypeInfo.INT_TYPE_INFO, Arrays.asList(10));
|
||||
assertEquals(1, tuple4._1);
|
||||
@@ -515,7 +511,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
assertNull(main.invoke(null, "IntelliJ"));
|
||||
}
|
||||
catch (Throwable t) {
|
||||
System.out.println(generateToText());
|
||||
// System.out.println(generateToText());
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user