public void testGeneralFunctions() { assertTranslation( "isFirst($goo)", new JsExpr("gooIndex8 == 0", Operator.EQUAL.getPrecedence())); assertTranslation( "not isLast($goo)", new JsExpr("! (gooIndex8 == gooListLen8 - 1)", Operator.NOT.getPrecedence())); assertTranslation( "index($goo) + 1", new JsExpr("gooIndex8 + 1", Operator.PLUS.getPrecedence())); }
public void testPrint() { assertGeneratedJsExprs( "{$boo.foo}", ImmutableList.of(new JsExpr("opt_data.boo.foo", Integer.MAX_VALUE))); assertGeneratedJsExprs( "{$goo.moo}", ImmutableList.of(new JsExpr("gooData8.moo", Integer.MAX_VALUE))); assertGeneratedJsExprs( "{index($goo)+1}", ImmutableList.of(new JsExpr("gooIndex8 + 1", Operator.PLUS.getPrecedence()))); }
public void testOperators() { assertTranslation( "not $boo or true and $goo", new JsExpr("! opt_data.boo || true && gooData8", Operator.OR.getPrecedence())); assertTranslation( "( (8-4) + (2-1) )", new JsExpr("8 - 4 + (2 - 1)", Operator.PLUS.getPrecedence())); assertTranslation( "$foo ?: 0", new JsExpr( "($$temp = opt_data.foo) == null ? 0 : $$temp", Operator.NULL_COALESCING.getPrecedence())); }