Class JepTest

java.lang.Object
com.singularsys.jeptests.system.JepTest
Direct Known Subclasses:
CPTest, ExtendedParserTest, NullWrapTest, PostfixEvalTest, StandardEvaluatorTest, UncheckedEvalTest

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

    • jep

      protected Jep jep
      The parser
    • myTrue

      protected Object myTrue
    • myFalse

      protected Object myFalse
  • Constructor Details

    • JepTest

      public JepTest()
  • Method Details

    • setUp

      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 Exception
      Test result j.evaluate(j.parse(expr))
      Parameters:
      expr - the expression to parse and evaluate
      expected - result expected
      Throws:
      Exception
    • calcValue

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

      protected Object calcValue(String expr) throws Exception
      Calculate the value of an expression.
      Parameters:
      expr -
      Throws:
      Exception
    • 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

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

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

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

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

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

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

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

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

      protected Object negativeZero()
    • testNumbers

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

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

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

      public void testNumberAsBooleanLogical() throws Exception
      Throws:
      Exception
    • testLogical

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      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

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

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

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

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

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

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

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

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

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

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

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

      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

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

      public void testListAccess() throws Exception
      Throws:
      Exception
    • testListAccessShiftZero

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

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

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

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

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

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

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

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

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

      protected void setShiftZeroElePfmc()