Skip to content

Commit

Permalink
Upgrade to jexl 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chbloemer committed Jan 5, 2024
1 parent a669bc7 commit e49f202
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import static org.graalvm.polyglot.HostAccess.newBuilder;

public class GraalJsExpressionHandler extends AbstractExpressionHandler {
JexlExpressionHandler jexlExpressionHandler = new JexlExpressionHandler();
final HostAccess all = newBuilder().allowAllImplementations(true).allowPublicAccess(true).allowArrayAccess(true).allowListAccess(true).allowMapAccess(true)
.targetTypeMapping(Integer.class, Object.class, null, (v) -> v)
.targetTypeMapping(Long.class, Object.class, null, (v) -> v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private String convertPlusPlusExpression(String expression) {

private String removeVar(String expression) {
expression = expression.replace("var ",";");
expression = expression.replace("let ",";");
expression = expression.replace("const ",";");
return expression;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,25 @@ public void testReturn() throws ExpressionException {
}

@Test
public void testInt() throws ExpressionException {
public void testIntVar() throws ExpressionException {
jexlExpressionHandler.evaluateExpression("var count = 5; var count2 = 6;", pugModel);
int count = (int) pugModel.get("count");
assertEquals(5,count);

}
@Test
public void testIntLet() throws ExpressionException {
jexlExpressionHandler.evaluateExpression("let count = 5; let count2 = 6;", pugModel);
int count = (int) pugModel.get("count");
assertEquals(5,count);

}
@Test
public void testIntConst() throws ExpressionException {
jexlExpressionHandler.evaluateExpression("const count = 5; const count2 = 6;", pugModel);
int count = (int) pugModel.get("count");
assertEquals(5,count);

}
@Test
public void testDoubleModel() throws ExpressionException {
Expand Down

0 comments on commit e49f202

Please sign in to comment.