support for calls in pattern matching

This commit is contained in:
Dmitry Jemerov
2011-07-06 16:29:45 +02:00
parent e61f69437d
commit 50a1eeeb59
2 changed files with 29 additions and 1 deletions
@@ -69,4 +69,11 @@ public class PatternMatchingTest extends CodegenTestCase {
assertEquals("one,two", foo.invoke(null, new Tuple2<Integer, Integer>(1, 2)));
assertEquals("something", foo.invoke(null, new Tuple2<String, String>("not", "tuple")));
}
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#"));
}
}