Class TestingVisitor

java.lang.Object
com.singularsys.jep.walkers.TestingVisitor
All Implemented Interfaces:
GenericVisitor<Boolean,Predicate<Node>,JepException>

public class TestingVisitor extends Object implements GenericVisitor<Boolean,Predicate<Node>,JepException>
A visitor than can test all nodes in a tree against a set of predicates. First a visitor is constructed and then the test(Node) method is called to test an expression.

This visitor checks all operators and functions have assigned pfmc's.

TestingVisitor tv = new TestingVisitor(
     n -> n instanceof ASTOpNode
          ? n.getPFMC()!=null
          : true,
     n -> n instanceof ASTFunNode
          ? n.getPFMC()!=null
          : true
       );

This visitor checks all literal constants are Doubles

TestingVisitor tv = new TestingVisitor(
     n -> n instanceof ASTConstant
          ? n.getValue() instanceof Double
          : true);

This visitor checks the assumption that PFMC of an operator node matches the PFMC of the operator.

TestingVisitor tv = new TestingVisitor(
    n -> n instanceof ASTOpNode
         ? n.getOperator().getPFMC() == n.getPFMC()
         : true);
Since:
Jep 4.1