pattern matching for expressions

This commit is contained in:
Dmitry Jemerov
2011-05-19 16:09:31 +02:00
parent c94b5ca312
commit 92a3e9275c
6 changed files with 136 additions and 12 deletions
@@ -0,0 +1,37 @@
package org.jetbrains.jet.codegen;
import jet.NoPatternMatchedException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* @author yole
*/
public class PatternMatchingTest extends CodegenTestCase {
@Override
protected String getPrefix() {
return "patternMatching";
}
public void testConstant() throws Exception {
loadFile();
Method foo = generateFunction();
assertTrue((Boolean) foo.invoke(null, 0));
assertFalse((Boolean) foo.invoke(null, 1));
}
public void testExceptionOnNoMatch() throws Exception {
loadFile();
Method foo = generateFunction();
assertTrue((Boolean) foo.invoke(null, 0));
boolean caught = false;
try {
foo.invoke(null, 1);
}
catch(InvocationTargetException ex) {
caught = ex.getTargetException() instanceof NoPatternMatchedException;
}
assertTrue(caught);
}
}