use of org.projectnessie.cel.EvalOption.OptTrackState in project cel-java by projectnessie.
the class CELTest method EvalRecover.
@Test
void EvalRecover() {
Env e = newEnv(declarations(Decls.newFunction("panic", Decls.newOverload("panic", singletonList(Type.getDefaultInstance()), Decls.Bool))));
ProgramOption funcs = functions(Overload.function("panic", args -> {
throw new RuntimeException("watch me recover");
}));
// Test standard evaluation.
AstIssuesTuple pAst = e.parse("panic()");
Program prgm1 = e.program(pAst.getAst(), funcs);
assertThatThrownBy(() -> prgm1.eval(emptyMap())).isExactlyInstanceOf(RuntimeException.class).hasMessage("internal error: watch me recover");
// Test the factory-based evaluation.
Program prgm2 = e.program(pAst.getAst(), funcs, evalOptions(OptTrackState));
assertThatThrownBy(() -> prgm2.eval(emptyMap())).isExactlyInstanceOf(RuntimeException.class).hasMessage("internal error: watch me recover");
}
Aggregations