type info for tuples and functions
This commit is contained in:
@@ -6,6 +6,7 @@ package org.jetbrains.jet.codegen;
|
||||
public class ClosuresGenTest extends CodegenTestCase {
|
||||
public void testSimplestClosure() throws Exception {
|
||||
blackBoxFile("classes/simplestClosure.jet");
|
||||
System.out.println(generateToText());
|
||||
}
|
||||
|
||||
public void testSimplestClosureAndBoxing() throws Exception {
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import jet.IntRange;
|
||||
import jet.Tuple2;
|
||||
import jet.Tuple3;
|
||||
import jet.Tuple4;
|
||||
import jet.typeinfo.TypeInfo;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
@@ -9,6 +11,7 @@ import java.awt.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -489,12 +492,23 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
|
||||
public void testTupleLiteral() throws Exception {
|
||||
loadText("fun foo() = (1, \"foo\")");
|
||||
System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Tuple2 tuple2 = (Tuple2) main.invoke(null);
|
||||
assertEquals(1, tuple2._1);
|
||||
assertEquals("foo", tuple2._2);
|
||||
}
|
||||
|
||||
public void testParametrizedTupleLiteral() throws Exception {
|
||||
loadText("fun <E,D> E.foo(extra: java.util.List<D>) = (1, \"foo\", this, extra)");
|
||||
System.out.println(generateToText());
|
||||
final Method main = generateFunction();
|
||||
Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", Arrays.asList(10), TypeInfo.STRING_TYPE_INFO, TypeInfo.INT_TYPE_INFO);
|
||||
assertEquals(1, tuple4._1);
|
||||
assertEquals("foo", tuple4._2);
|
||||
assertEquals("aaa", tuple4._3);
|
||||
}
|
||||
|
||||
public void testPredicateOperator() throws Exception {
|
||||
loadText("fun foo(s: String) = s?startsWith(\"J\")");
|
||||
final Method main = generateFunction();
|
||||
|
||||
@@ -90,13 +90,13 @@ public class PatternMatchingTest extends CodegenTestCase {
|
||||
Method foo = generateFunction();
|
||||
final Object result;
|
||||
try {
|
||||
result = foo.invoke(null, new Tuple2<Integer, Integer>(1, 2));
|
||||
result = foo.invoke(null, new Tuple2<Integer, Integer>(null, 1, 2));
|
||||
} catch (Exception e) {
|
||||
System.out.println(generateToText());
|
||||
throw e;
|
||||
}
|
||||
assertEquals("one,two", result);
|
||||
assertEquals("something", foo.invoke(null, new Tuple2<String, String>("not", "tuple")));
|
||||
assertEquals("something", foo.invoke(null, new Tuple2<String, String>(null, "not", "tuple")));
|
||||
}
|
||||
|
||||
public void testCall() throws Exception {
|
||||
@@ -119,8 +119,8 @@ public class PatternMatchingTest extends CodegenTestCase {
|
||||
public void testNames() throws Exception {
|
||||
loadText("fun foo(x: (Any, Any)) = when(x) { is (val a is String, *) => a; else => \"something\" }");
|
||||
Method foo = generateFunction();
|
||||
assertEquals("JetBrains", foo.invoke(null, new Tuple2<String, String>("JetBrains", "s.r.o.")));
|
||||
assertEquals("something", foo.invoke(null, new Tuple2<Integer, Integer>(1, 2)));
|
||||
assertEquals("JetBrains", foo.invoke(null, new Tuple2<String, String>(null, "JetBrains", "s.r.o.")));
|
||||
assertEquals("something", foo.invoke(null, new Tuple2<Integer, Integer>(null, 1, 2)));
|
||||
}
|
||||
|
||||
public void testMultipleConditions() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user