KT-894 wrong string concatenation
This commit is contained in:
@@ -1,11 +1,58 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class StringsTest extends CodegenTestCase {
|
||||
|
||||
public void testAnyToString () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: Any) = x.toString()");
|
||||
// System.out.println(generateToText());
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something", foo.invoke(null, "something"));
|
||||
assertEquals("null", foo.invoke(null, new Object[]{null}));
|
||||
|
||||
}
|
||||
|
||||
public void testNullableAnyToString () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: Any?) = x.toString()");
|
||||
// System.out.println(generateToText());
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something", foo.invoke(null, "something"));
|
||||
assertEquals("null", foo.invoke(null, new Object[]{null}));
|
||||
|
||||
}
|
||||
|
||||
public void testNullableStringPlus () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: String?, y: Any?) = x + y");
|
||||
String text = generateToText();
|
||||
assertTrue(text.contains(".stringPlus"));
|
||||
// System.out.println(text);
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something239", foo.invoke(null, "something", 239));
|
||||
assertEquals("null239", foo.invoke(null, null, 239));
|
||||
assertEquals("239null", foo.invoke(null, "239", null));
|
||||
assertEquals("nullnull", foo.invoke(null, null, null));
|
||||
|
||||
}
|
||||
|
||||
public void testNonNullableStringPlus () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: String, y: Any?) = x + y + 120");
|
||||
String text = generateToText();
|
||||
assertFalse(text.contains(".stringPlus"));
|
||||
// System.out.println(text);
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something239120", foo.invoke(null, "something", 239));
|
||||
assertEquals("null239120", foo.invoke(null, null, 239));
|
||||
assertEquals("239null120", foo.invoke(null, "239", null));
|
||||
assertEquals("nullnull120", foo.invoke(null, null, null));
|
||||
|
||||
}
|
||||
|
||||
public void testRawStrings() throws Exception {
|
||||
blackBoxFile("rawStrings.jet");
|
||||
}
|
||||
@@ -13,4 +60,8 @@ public class StringsTest extends CodegenTestCase {
|
||||
public void testKt881() throws Exception {
|
||||
blackBoxFile("regressions/kt881.jet");
|
||||
}
|
||||
|
||||
public void testKt894() throws Exception {
|
||||
blackBoxFile("regressions/kt894.jet");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user