failing test for throw
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user