Class JepTest

java.lang.Object
com.singularsys.jeptests.system.JepTest
Direct Known Subclasses:
BigDecimalStandardTests, CPTest, ExtendedParserTest, FieldTest, JepTestWithCustomNumberType, NullWrapTest, PostfixEvalTest, RpTest, StandardEvaluatorTest, UncheckedEvalTest, XJepTest, XJepXAssignTest

public class JepTest extends Object
Tests various functions on the Jep class. The current implementation tests using the default setup with the JavaCC parser.

Printing of tests can be supressed by setting the DO_NOT_PRINT_TESTS environment variable

  • Field Details

    • jep

      protected Jep jep
      The parser
    • myTrue

      protected Object myTrue
    • myFalse

      protected Object myFalse
  • Constructor Details

    • JepTest

      public JepTest()
  • Method Details

    • setUp

      @BeforeEach public void setUp()
      Sets up the parser.
    • printTestHeader

      protected void printTestHeader(String str)
      Prints a header with the name of the test as specified in str.
    • valueTest

      protected void valueTest(String expr, Object expected) throws JepException
      Test result j.evaluate(j.parse(expr))
      Parameters:
      expr - the expression to parse and evaluate
      expected - result expected
      Throws:
      JepException
    • calcValue

      protected Object calcValue(Node node) throws JepException
      Calculate the value of an expression.
      Parameters:
      node -
      Throws:
      JepException
    • getNumber

      protected Object getNumber(Object val)
      Create a number of the appropriate type
      Parameters:
      val - input
      Returns:
      converted number
    • negativeZero

      protected Object negativeZero()
    • calcValue

      protected Object calcValue(String expr) throws JepException
      Calculate the value of an expression.
      Parameters:
      expr -
      Throws:
      JepException
    • myAssertEquals

      protected void myAssertEquals(String msg, Object expected, Object actual) throws EvaluationException
      Throws:
      EvaluationException
    • myAssertNaN

      protected void myAssertNaN(String msg, Object actual)
    • myAssertNull

      protected void myAssertNull(String msg, Object actual)
    • valueTestNull

      protected void valueTestNull(String expr) throws Exception
      Throws:
      Exception
    • valueTestNaN

      protected void valueTestNaN(String expr) throws Exception
      Test whether an expression evaluates to NaN
      Parameters:
      expr -
      Throws:
      Exception
    • valueTestFail

      protected void valueTestFail(String expr) throws Exception
      Test whether evaluating an expression results in an exception
      Parameters:
      expr -
      Throws:
      Exception
    • valueTestString

      protected void valueTestString(String expr, String expected) throws Exception
      Throws:
      Exception
    • complexValueTest

      protected void complexValueTest(String expr, Complex expected, double tol) throws Exception
      Test parse-evaluate with complex number and given tolerance.
      Parameters:
      expr -
      expected -
      tol -
      Throws:
      Exception
    • valueTest

      protected void valueTest(String expr, double a, double tol) throws Exception
      Test values to within a given precision
      Parameters:
      expr - expression
      a - the expected value
      tol - tolerance
      Throws:
      Exception
    • nodeTest

      public static void nodeTest(Node n, Operator op)
    • nodeTest

      public static void nodeTest(Node n, String name)
    • nodeTest

      public static void nodeTest(Node n, Variable v)
    • nodeTest

      public static void nodeTest(Node n, Object v)
    • compareRecursive

      protected boolean compareRecursive(Node node1, Node node2)
    • assertEqNodes

      protected void assertEqNodes(String s, Node expected, Node actual)
    • testSimpleSum

      @Test public void testSimpleSum() throws Exception
      Throws:
      Exception
    • testEvaluate

      @Test public void testEvaluate() throws Exception
      Tests the evaluate() method.
      Throws:
      Exception
    • test_parser_sets_parent

      @Test public void test_parser_sets_parent() throws Exception
      Throws:
      Exception
    • testEvaluateComplex

      @Test public void testEvaluateComplex() throws Exception
      Throws:
      Exception
    • testEvaluateString

      @Test public void testEvaluateString() throws Exception
      Throws:
      Exception
    • testChangeVariable

      @Test public void testChangeVariable() throws Exception
      Test changing variables value after parsing
      Throws:
      Exception
    • testChangeVariableComplex

      @Test public void testChangeVariableComplex() throws Exception
      Test changing variables value after parsing
      Throws:
      Exception
    • testSetAllowUndeclared

      @Test public void testSetAllowUndeclared() throws Exception
      Tests whether allowUndeclared is working properly.
      Throws:
      Exception
    • testNumbers

      @Test public void testNumbers() throws Exception
      Throws:
      Exception
    • testStrings

      @Test public void testStrings() throws Exception
      Throws:
      Exception
    • testStringsFun

      @Test public void testStringsFun() throws Exception
      Throws:
      Exception
    • testNumberAsBooleanLogical

      @Test public void testNumberAsBooleanLogical() throws Exception
      Throws:
      Exception
    • test_adding_existing_constant_fails

      @Test public void test_adding_existing_constant_fails() throws Exception
      Throws:
      Exception
    • testLogical

      @Test public void testLogical() throws Exception
      Throws:
      Exception
    • testNull

      @Test public void testNull() throws Exception
      Throws:
      Exception
    • testNaN

      @Test public void testNaN() throws Exception
      Throws:
      Exception
    • testComplex

      @Test public void testComplex() throws Exception
      Throws:
      Exception
    • testFunction

      @Test public void testFunction() throws Exception
      Throws:
      Exception
    • testIf

      @Test public void testIf() throws Exception
      Throws:
      Exception
    • testPlusPlus

      @Test public void testPlusPlus() throws Exception
      Throws:
      Exception
    • testImplicitMul

      @Test public void testImplicitMul() throws Exception
      Throws:
      Exception
    • testUminusPower

      @Test public void testUminusPower() throws Exception
      Throws:
      Exception
    • testNumParam

      @Test public void testNumParam() throws Exception
      Throws:
      Exception
    • testBinom

      @Test public void testBinom() throws Exception
      Throws:
      Exception
    • testFormat

      @Test public void testFormat() throws Exception
      Throws:
      Exception
    • testAssign

      @Test public void testAssign() throws Exception
      Throws:
      Exception
    • testMultiplyBug

      @Test public void testMultiplyBug() throws Exception
      Throws:
      Exception
    • testNoAssign

      @Test public void testNoAssign() throws Exception
      Throws:
      Exception
    • testLazyLogical

      @Test public void testLazyLogical() throws Exception
      Throws:
      Exception
    • testLazyLogical2

      @Test public void testLazyLogical2() throws Exception
      Throws:
      Exception
    • testLazyLogicalBug

      @Test public void testLazyLogicalBug() throws Exception
      Test for bug with 1&&1&&1
      Throws:
      Exception
    • testLogarithm

      @Test public void testLogarithm() throws Exception
      Throws:
      Exception
    • testBlankParser

      @Test public void testBlankParser() throws Exception
      Test creating a Jep instance with no functions and no variables.
      Throws:
      Exception
    • testMacroFunction

      @Test public void testMacroFunction() throws Exception
      Throws:
      Exception
    • testRecursiveMacroFunction

      @Test public void testRecursiveMacroFunction() throws Exception
      Throws:
      Exception
    • testParseException

      @Test public void testParseException()
      Tests whether a parse exceptions are thrown when they should be. See ticket #50 Tests on both the standard parser and the configurable parser, is carried out by CPTest which extends this.
    • testEvalExceptions

      @Test public void testEvalExceptions()
      Test whether evaluation exceptions are thrown when they should be.
    • testSemiColon

      @Test public void testSemiColon() throws Exception
      Throws:
      Exception
    • testMultiLine

      @Test public void testMultiLine() throws Exception
      Throws:
      Exception
    • testEmptyEqn

      @Test public void testEmptyEqn() throws Exception
      Throws:
      Exception
    • testComments

      @Test public void testComments() throws Exception
      Throws:
      Exception
    • testEmptyEqn2

      @Test public void testEmptyEqn2() throws Exception
      Throws:
      Exception
    • test_not_X_Y

      @Test public void test_not_X_Y() throws Exception
      Throws:
      Exception
    • testX2Y

      @Test public void testX2Y() throws Exception
      Throws:
      Exception
    • testExpectedTokenSequence

      @Test public void testExpectedTokenSequence()
      Tests for bug #52
    • testSwitch

      @Test public void testSwitch() throws Exception
      Throws:
      Exception
    • testCaseString

      @Test public void testCaseString() throws Exception
      Throws:
      Exception
    • testCaseNull

      @Test public void testCaseNull() throws Exception
      Throws:
      Exception
    • buildVector

      protected Object buildVector(Object... eles) throws Exception
      Throws:
      Exception
    • buildMatrix

      protected Object buildMatrix(Object[]... eles) throws Exception
      Throws:
      Exception
    • testComplexListAccess

      @Test public void testComplexListAccess() throws Exception
      Throws:
      Exception
    • testListAccess

      @Test public void testListAccess() throws Exception
      Throws:
      Exception
    • testListOperations

      @Test public void testListOperations() throws Exception
      Throws:
      Exception
    • testListAccessShiftZero

      @Test public void testListAccessShiftZero() throws Exception
      Throws:
      Exception
    • checkVector

      public void checkVector(Object[] expected, Object actual) throws EvaluationException
      Throws:
      EvaluationException
    • testEleUnit

      @Test public void testEleUnit() throws Exception
      Throws:
      Exception
    • testMultiDimArray

      @Test public void testMultiDimArray() throws Exception
      Throws:
      Exception
    • testMultiDimArrayShiftZero

      @Test public void testMultiDimArrayShiftZero() throws Exception
      Throws:
      Exception
    • testListFunctions

      @Test public void testListFunctions() throws Exception
      Throws:
      Exception
    • testListExtra

      @Test public void testListExtra() throws Exception
      Throws:
      Exception
    • testSpecialFunctions

      @Test public void testSpecialFunctions() throws Exception
      Throws:
      Exception
    • testSpecialFunctions

      public void testSpecialFunctions(boolean hasRealEval, boolean hasCallback) throws Exception
      Throws:
      Exception
    • setShiftZeroElePfmc

      protected void setShiftZeroElePfmc()