Merge remote branch 'origin/master'
Conflicts: idea/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
This commit is contained in:
@@ -168,4 +168,13 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
final Method rgbMethod = colorClass.getMethod("getRgb");
|
||||
assertEquals(0xFF0000, rgbMethod.invoke(redValue));
|
||||
}
|
||||
|
||||
public void testKt249() throws Exception {
|
||||
blackBoxFile("regressions/kt249.jet");
|
||||
}
|
||||
|
||||
public void testKt48 () throws Exception {
|
||||
blackBoxFile("regressions/kt48.jet");
|
||||
System.out.println(generateToText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,4 +140,41 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
assertTrue(caught);
|
||||
assertEquals("foobar", sb.toString());
|
||||
}
|
||||
|
||||
public void testForUserType() throws Exception {
|
||||
blackBoxFile("controlStructures/forUserType.jet");
|
||||
}
|
||||
|
||||
public void testKt237() throws Exception {
|
||||
blackBoxFile("regressions/kt237.jet");
|
||||
}
|
||||
|
||||
public void testCompareToNull() throws Exception {
|
||||
loadText("fun foo(a: String?, b: String?): Boolean = a == null && b !== null && null == a && null !== b");
|
||||
String text = generateToText();
|
||||
assertTrue(!text.contains("java/lang/Object.equals"));
|
||||
System.out.println(text);
|
||||
final Method main = generateFunction();
|
||||
assertEquals(true, main.invoke(null, null, "lala"));
|
||||
assertEquals(false, main.invoke(null, null, null));
|
||||
}
|
||||
|
||||
public void testCompareToNonnullableEq() throws Exception {
|
||||
loadText("fun foo(a: String?, b: String): Boolean = a == b || b == a");
|
||||
String text = generateToText();
|
||||
System.out.println(text);
|
||||
final Method main = generateFunction();
|
||||
assertEquals(false, main.invoke(null, null, "lala"));
|
||||
assertEquals(true, main.invoke(null, "papa", "papa"));
|
||||
}
|
||||
|
||||
public void testCompareToNonnullableNotEq() throws Exception {
|
||||
loadText("fun foo(a: String?, b: String): Boolean = a != b");
|
||||
String text = generateToText();
|
||||
System.out.println(text);
|
||||
assertTrue(text.contains("IXOR"));
|
||||
final Method main = generateFunction();
|
||||
assertEquals(true, main.invoke(null, null, "lala"));
|
||||
assertEquals(false, main.invoke(null, "papa", "papa"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +209,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());
|
||||
assertEquals(Boolean.TRUE, main.invoke(null, null, null));
|
||||
assertEquals(Boolean.FALSE, main.invoke(null, "jet", null));
|
||||
assertEquals(Boolean.FALSE, main.invoke(null, null, "jet"));
|
||||
@@ -217,6 +218,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());
|
||||
assertEquals(Boolean.TRUE, main.invoke(null, new Object[] { null }));
|
||||
assertEquals(Boolean.FALSE, main.invoke(null, "jet"));
|
||||
}
|
||||
@@ -448,8 +450,14 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
public void testPredicateOperator() throws Exception {
|
||||
loadText("fun foo(s: String) = s?startsWith(\"J\")");
|
||||
final Method main = generateFunction();
|
||||
try {
|
||||
assertEquals("JetBrains", main.invoke(null, "JetBrains"));
|
||||
assertNull(main.invoke(null, "IntelliJ"));
|
||||
}
|
||||
catch (Throwable t) {
|
||||
System.out.println(generateToText());
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void testEscapeSequence() throws Exception {
|
||||
|
||||
@@ -35,12 +35,28 @@ public class PatternMatchingTest extends CodegenTestCase {
|
||||
assertEquals("something", foo.invoke(null, new Object()));
|
||||
}
|
||||
|
||||
public void testInrange() throws Exception {
|
||||
loadFile();
|
||||
System.out.println(generateToText());
|
||||
Method foo = generateFunction();
|
||||
assertEquals("array list", foo.invoke(null, 239));
|
||||
assertEquals("digit", foo.invoke(null, 0));
|
||||
assertEquals("digit", foo.invoke(null, 9));
|
||||
assertEquals("digit", foo.invoke(null, 5));
|
||||
assertEquals("not small", foo.invoke(null, 190));
|
||||
assertEquals("something", foo.invoke(null, 19));
|
||||
}
|
||||
|
||||
public void testRange() throws Exception {
|
||||
loadFile();
|
||||
System.out.println(generateToText());
|
||||
Method foo = generateFunction();
|
||||
assertEquals("array list", foo.invoke(null, 239));
|
||||
assertEquals("digit", foo.invoke(null, 0));
|
||||
assertEquals("digit", foo.invoke(null, 9));
|
||||
assertEquals("digit", foo.invoke(null, 5));
|
||||
assertEquals("something", foo.invoke(null, 19));
|
||||
assertEquals("not small", foo.invoke(null, 190));
|
||||
}
|
||||
|
||||
public void testRangeChar() throws Exception {
|
||||
@@ -80,8 +96,14 @@ public class PatternMatchingTest extends CodegenTestCase {
|
||||
public void testCall() throws Exception {
|
||||
loadText("fun foo(s: String) = when(s) { .startsWith(\"J\") => \"JetBrains\"; else => \"something\" }");
|
||||
Method foo = generateFunction();
|
||||
assertEquals("JetBrains", foo.invoke(null, "Java"));
|
||||
assertEquals("something", foo.invoke(null, "C#"));
|
||||
try {
|
||||
assertEquals("JetBrains", foo.invoke(null, "Java"));
|
||||
assertEquals("something", foo.invoke(null, "C#"));
|
||||
}
|
||||
catch (Throwable t) {
|
||||
System.out.println(generateToText());
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void testCallProperty() throws Exception {
|
||||
|
||||
@@ -134,4 +134,10 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
public void testKt257 () throws Exception {
|
||||
blackBoxFile("regressions/kt257.jet");
|
||||
}
|
||||
|
||||
public void testKt160() throws Exception {
|
||||
loadText("public val s = java.lang.Double.toString(1.0)");
|
||||
final Method method = generateFunction("getS");
|
||||
assertEquals(method.invoke(null), "1.0");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user