use of com.oracle.truffle.api.instrumentation.test.UnwindReenterReturnTest.TestControlFlow.CodeAction in project graal by oracle.
the class UnwindReenterReturnTest method testUnwindReenterOnException.
@Test
public void testUnwindReenterOnException() throws Exception {
List<CodeAction> actionsUnwind = new ArrayList<>();
List<CodeAction> actionsReenter = new ArrayList<>();
// Unwind at DEFINE() and Reenter after pop from CALL(a):
actionsUnwind.add(new CodeAction("STATEMENT(DEFINE(a, ROOT()))", TestControlFlow.ACTION.UNWIND, "3uw"));
actionsReenter.add(new CodeAction("CALL(a)", TestControlFlow.ACTION.REENTER));
testControlFlow.actions.put(TestControlFlow.WHERE.RETURN_EXCEPTIONAL, actionsUnwind);
testControlFlow.actions.put(TestControlFlow.WHERE.UNWIND, actionsReenter);
String message = null;
try {
run(CODE2_EXC);
fail();
} catch (PolyglotException pe) {
message = pe.getMessage();
assertTrue(message, message.contains("Identifier redefinition not supported"));
}
assertEquals(0, actionsUnwind.size());
assertEquals(0, actionsReenter.size());
assertEquals("[CALL(a), CALL(b), STATEMENT(DEFINE(a, ROOT())), CALL(a), CALL(b), STATEMENT(DEFINE(a, ROOT()))]", testControlFlow.nodesEntered.toString());
assertEquals("[STATEMENT(DEFINE(a, ROOT())), CALL(b), CALL(a), STATEMENT(DEFINE(a, ROOT())), CALL(b), CALL(a)]", testControlFlow.nodesReturned.toString());
String uw = "com.oracle.truffle.api.instrumentation.UnwindException";
assertEquals("[" + message + ", " + uw + ", " + uw + ", " + message + ", " + message + ", " + message + "]", testControlFlow.returnValuesExceptions.toString());
assertEquals("[STATEMENT(DEFINE(a, ROOT())), CALL(b), CALL(a)]", testControlFlow.nodesUnwound.toString());
assertEquals("[3uw, 3uw, 3uw]", testControlFlow.unwoundInfos.toString());
}
use of com.oracle.truffle.api.instrumentation.test.UnwindReenterReturnTest.TestControlFlow.CodeAction in project graal by oracle.
the class UnwindReenterReturnTest method testUnwindReturnOnEnter.
@Test
public void testUnwindReturnOnEnter() throws Exception {
List<CodeAction> actionsUnwind = new ArrayList<>();
List<CodeAction> actionsReenter = new ArrayList<>();
// Unwind at STATEMENT() and Return after pop from CALL(a):
actionsUnwind.add(new CodeAction("STATEMENT()", TestControlFlow.ACTION.UNWIND, "3uw"));
actionsReenter.add(new CodeAction("CALL(a)", TestControlFlow.ACTION.RETURN, 42));
testControlFlow.actions.put(TestControlFlow.WHERE.ENTER, actionsUnwind);
testControlFlow.actions.put(TestControlFlow.WHERE.UNWIND, actionsReenter);
int ret = context.eval(lines(CODE2)).asInt();
assertEquals(42, ret);
assertEquals(0, actionsUnwind.size());
assertEquals(0, actionsReenter.size());
assertEquals("[CALL(a), CALL(b), STATEMENT()]", testControlFlow.nodesEntered.toString());
assertEquals("[STATEMENT(), CALL(b), CALL(a)]", testControlFlow.nodesReturned.toString());
String uw = "com.oracle.truffle.api.instrumentation.UnwindException";
assertEquals("[" + uw + ", " + uw + ", " + uw + "]", testControlFlow.returnValuesExceptions.toString());
assertEquals("[STATEMENT(), CALL(b), CALL(a)]", testControlFlow.nodesUnwound.toString());
assertEquals("[3uw, 3uw, 3uw]", testControlFlow.unwoundInfos.toString());
}
use of com.oracle.truffle.api.instrumentation.test.UnwindReenterReturnTest.TestControlFlow.CodeAction in project graal by oracle.
the class UnwindReenterReturnTest method testUnwindReenterOnEnter.
@Test
public void testUnwindReenterOnEnter() throws Exception {
List<CodeAction> actionsUnwind = new ArrayList<>();
List<CodeAction> actionsReenter = new ArrayList<>();
// Unwind at STATEMENT() and Reenter after pop from CALL(a):
actionsUnwind.add(new CodeAction("STATEMENT()", TestControlFlow.ACTION.UNWIND, "3uw"));
actionsReenter.add(new CodeAction("CALL(a)", TestControlFlow.ACTION.REENTER));
testControlFlow.actions.put(TestControlFlow.WHERE.ENTER, actionsUnwind);
testControlFlow.actions.put(TestControlFlow.WHERE.UNWIND, actionsReenter);
run(CODE2);
assertEquals(0, actionsUnwind.size());
assertEquals(0, actionsReenter.size());
assertEquals("[CALL(a), CALL(b), STATEMENT(), CALL(a), CALL(b), STATEMENT()]", testControlFlow.nodesEntered.toString());
assertEquals("[STATEMENT(), CALL(b), CALL(a), STATEMENT(), CALL(b), CALL(a)]", testControlFlow.nodesReturned.toString());
String uw = "com.oracle.truffle.api.instrumentation.UnwindException";
assertEquals("[" + uw + ", " + uw + ", " + uw + ", Null, Null, Null]", testControlFlow.returnValuesExceptions.toString());
assertEquals("[STATEMENT(), CALL(b), CALL(a)]", testControlFlow.nodesUnwound.toString());
assertEquals("[3uw, 3uw, 3uw]", testControlFlow.unwoundInfos.toString());
}
Aggregations