string templates
This commit is contained in:
@@ -451,4 +451,16 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
assertEquals("JetBrains", main.invoke(null, "JetBrains"));
|
||||
assertNull(main.invoke(null, "IntelliJ"));
|
||||
}
|
||||
|
||||
public void testEscapeSequence() throws Exception {
|
||||
loadText("fun foo() = \"a\\nb\\$\"");
|
||||
final Method main = generateFunction();
|
||||
assertEquals("a\nb$", main.invoke(null));
|
||||
}
|
||||
|
||||
public void testStringTemplate() throws Exception {
|
||||
loadText("fun foo(a: String) = \"IntelliJ $a Rulezzz\"");
|
||||
final Method main = generateFunction();
|
||||
assertEquals("IntelliJ IDEA Rulezzz", main.invoke(null, "IDEA"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,14 @@ public class PatternMatchingTest extends CodegenTestCase {
|
||||
public void testTuplePattern() throws Exception {
|
||||
loadText("fun foo(x: (Any, Any)) = when(x) { is (1,2) => \"one,two\"; else => \"something\" }");
|
||||
Method foo = generateFunction();
|
||||
assertEquals("one,two", foo.invoke(null, new Tuple2<Integer, Integer>(1, 2)));
|
||||
final Object result;
|
||||
try {
|
||||
result = foo.invoke(null, new Tuple2<Integer, Integer>(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")));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user