Search in sources :

Example 21 with Op

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=* & "));
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Example 22 with Op

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());
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Example 23 with Op

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));
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Example 24 with 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] "));
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Example 25 with Op

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;
}
Also used : NotExistsOp(uk.me.parabola.mkgmap.osmstyle.eval.NotExistsOp) Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) GTEOp(uk.me.parabola.mkgmap.osmstyle.eval.GTEOp) LTOp(uk.me.parabola.mkgmap.osmstyle.eval.LTOp) NotEqualOp(uk.me.parabola.mkgmap.osmstyle.eval.NotEqualOp) BinaryOp(uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp) OrOp(uk.me.parabola.mkgmap.osmstyle.eval.OrOp) NotOp(uk.me.parabola.mkgmap.osmstyle.eval.NotOp) ValueOp(uk.me.parabola.mkgmap.osmstyle.eval.ValueOp) EqualsOp(uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp) RegexOp(uk.me.parabola.mkgmap.osmstyle.eval.RegexOp) ExistsOp(uk.me.parabola.mkgmap.osmstyle.eval.ExistsOp) AndOp(uk.me.parabola.mkgmap.osmstyle.eval.AndOp) NodeType(uk.me.parabola.mkgmap.osmstyle.eval.NodeType) BinaryOp(uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp)

Aggregations

Op (uk.me.parabola.mkgmap.osmstyle.eval.Op)35 LinkedOp (uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp)28 Test (org.junit.Test)17 EqualsOp (uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp)16 ValueOp (uk.me.parabola.mkgmap.osmstyle.eval.ValueOp)16 AndOp (uk.me.parabola.mkgmap.osmstyle.eval.AndOp)12 BinaryOp (uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp)12 ExistsOp (uk.me.parabola.mkgmap.osmstyle.eval.ExistsOp)12 GTEOp (uk.me.parabola.mkgmap.osmstyle.eval.GTEOp)12 LTOp (uk.me.parabola.mkgmap.osmstyle.eval.LTOp)12 NotEqualOp (uk.me.parabola.mkgmap.osmstyle.eval.NotEqualOp)12 NotExistsOp (uk.me.parabola.mkgmap.osmstyle.eval.NotExistsOp)12 OrOp (uk.me.parabola.mkgmap.osmstyle.eval.OrOp)12 RegexOp (uk.me.parabola.mkgmap.osmstyle.eval.RegexOp)12 AbstractOp (uk.me.parabola.mkgmap.osmstyle.eval.AbstractOp)11 GTOp (uk.me.parabola.mkgmap.osmstyle.eval.GTOp)9 LTEOp (uk.me.parabola.mkgmap.osmstyle.eval.LTEOp)9 NotRegexOp (uk.me.parabola.mkgmap.osmstyle.eval.NotRegexOp)9 NotOp (uk.me.parabola.mkgmap.osmstyle.eval.NotOp)7 ArrayList (java.util.ArrayList)5