JVM Back-end does not handle complex patterns any more

#KT-2359 In Progress
This commit is contained in:
Andrey Breslav
2012-09-05 12:53:32 +04:00
parent 756ca9b284
commit 4dd0b27e93
2 changed files with 35 additions and 120 deletions
@@ -16,7 +16,6 @@
package org.jetbrains.jet.codegen;
import jet.Tuple2;
import org.jetbrains.jet.ConfigurationKind;
import java.lang.reflect.Method;
@@ -97,13 +96,13 @@ public class PatternMatchingTest extends CodegenTestCase {
}
public void testWildcardPattern() throws Exception {
loadText("fun foo(x: String) = when(x) { is * -> \"something\" }");
loadText("fun foo(x: String) = when(x) { else -> \"something\" }");
Method foo = generateFunction();
assertEquals("something", foo.invoke(null, ""));
}
public void testNoReturnType() throws Exception {
loadText("fun foo(x: String) = when(x) { is * -> \"x\" }");
loadText("fun foo(x: String) = when(x) { else -> \"x\" }");
Method foo = generateFunction();
assertEquals("x", foo.invoke(null, ""));
}
@@ -119,15 +118,8 @@ public class PatternMatchingTest extends CodegenTestCase {
blackBoxFile("patternMatching/callProperty.jet");
}
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)));
}
public void testMultipleConditions() throws Exception {
loadText("fun foo(x: Any) = when(x) { is 0, 1 -> \"bit\"; else -> \"something\" }");
loadText("fun foo(x: Any) = when(x) { 0, 1 -> \"bit\"; else -> \"something\" }");
Method foo = generateFunction();
assertEquals("bit", foo.invoke(null, 0));
assertEquals("bit", foo.invoke(null, 1));