failing test for throw

This commit is contained in:
Dmitry Jemerov
2011-04-21 18:01:58 +02:00
parent 11f8ed8c28
commit 843c102922
2 changed files with 20 additions and 0 deletions
@@ -1001,6 +1001,12 @@ public class ExpressionCodegen extends JetVisitor {
gen(indices.get(0), Type.INT_TYPE);
}
@Override
public void visitThrowExpression(JetThrowExpression expression) {
gen(expression.getThrownExpression(), JetTypeMapper.TYPE_OBJECT);
v.athrow();
}
private static class CompilationException extends RuntimeException {
}
}
@@ -85,4 +85,18 @@ public class ControlStructuresTest extends CodegenTestCase {
String[] args = new String[] { "IntelliJ", " ", "IDEA" };
assertEquals("IntelliJ IDEA", main.invoke(null, new Object[] { args }));
}
public void testThrowCheckedException() throws Exception {
loadText("fun foo() { throw new Exception(); }");
final Method main = generateFunction();
boolean caught = false;
try {
main.invoke(null);
} catch (InvocationTargetException e) {
if (e.getTargetException().getClass() == Exception.class) {
caught = true;
}
}
assertTrue(caught);
}
}