use of uk.me.parabola.mkgmap.osmstyle.eval.Op in project mkgmap by openstreetmap.
the class ExpressionArrangerTest method testChainAndWithBracketedAnd.
@Test
public void testChainAndWithBracketedAnd() {
Op op = createOp("(a>2 & b~h) & (c=* & d=hello) & fred<3 [0x2]");
op = arranger.arrange(op);
assertTrue(fmtExpr(op).startsWith("$d=hello [AND] $c=* & "));
}
use of uk.me.parabola.mkgmap.osmstyle.eval.Op in project mkgmap by openstreetmap.
the class ExpressionArrangerTest method testStartDoubleNot.
@Test
public void testStartDoubleNot() {
Op op = createOp("!!(a<2 & b=foo)");
op = arranger.arrange(op);
assertEquals("$b=foo & $a<2", op.toString());
}
use of uk.me.parabola.mkgmap.osmstyle.eval.Op in project mkgmap by openstreetmap.
the class ExpressionArrangerTest method testIsSolved.
@Test
public void testIsSolved() {
String s = "$a=2 | $a=1 & $a!=1 | $b=2 & $a!=1 | $b<1";
Op op = createOp(s);
assertTrue(isSolved(op));
op = arranger.arrange(op);
assertTrue(isSolved(op));
}
use of uk.me.parabola.mkgmap.osmstyle.eval.Op in project mkgmap by openstreetmap.
the class ExpressionArrangerTest method testPoorInitialSwap.
@Test
public void testPoorInitialSwap() {
Op op = createOp("!($b=1) & $b!=1 & $b!=2 & $b=1 {name 'n770'} [0x2]");
op = arranger.arrange(op);
System.out.println(fmtExpr(op));
assertTrue(fmtExpr(op).startsWith("$b=1 [AND] "));
}
use of uk.me.parabola.mkgmap.osmstyle.eval.Op in project mkgmap by openstreetmap.
the class RulesTest method checkNotLength.
public static boolean checkNotLength(Op expr, boolean hasNot) {
if (expr == null)
return false;
Op f = expr.getFirst();
if (hasNot && f != null && f.isType(FUNCTION) && Objects.equals(f.toString(), "length()"))
return true;
boolean invalid = false;
NodeType t = expr.getType();
if (expr instanceof BinaryOp) {
if (checkNotLength(expr.getFirst(), hasNot))
invalid = true;
if (checkNotLength(expr.getSecond(), hasNot))
invalid = true;
} else if (t == NOT) {
if (checkNotLength(expr.getFirst(), true))
invalid = true;
}
return invalid;
}
Aggregations