use of org.projectnessie.cel.Program.EvalResult in project cel-java by projectnessie.
the class CELTest method residualAst_Modified.
@Test
void residualAst_Modified() {
Env e = newEnv(declarations(Decls.newVar("x", Decls.newMapType(Decls.String, Decls.Int)), Decls.newVar("y", Decls.Int)));
AstIssuesTuple astIss = e.parse("x == y");
Program prg = e.program(astIss.getAst(), evalOptions(OptTrackState, OptPartialEval));
for (int x = 123; x < 456; x++) {
PartialActivation vars = partialVars(mapOf("x", x), attributePattern("y"));
EvalResult outDet = prg.eval(vars);
assertThat(outDet.getVal()).matches(UnknownT::isUnknown);
Ast residual = e.residualAst(astIss.getAst(), outDet.getEvalDetails());
String orig = astToString(astIss.getAst());
assertThat(orig).isEqualTo("x == y");
String expr = astToString(residual);
String want = String.format("%d == y", x);
assertThat(expr).isEqualTo(want);
}
}
Aggregations