Package com.singularsys.jeptests.system
Class JepTest
java.lang.Object
com.singularsys.jeptests.system.JepTest
- Direct Known Subclasses:
CPTest,ExtendedParserTest,NullWrapTest,PostfixEvalTest,StandardEvaluatorTest,UncheckedEvalTest
Tests various functions on the Jep class.
The current implementation tests using the default setup with the JavaCC
parser.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertEqNodes(String s, Node expected, Node actual) protected ObjectbuildMatrix(Object[]... eles) protected ObjectbuildVector(Object... eles) protected ObjectCalculate the value of an expression.protected ObjectCalculate the value of an expression.voidcheckVector(Object[] expected, Object actual) protected booleancompareRecursive(Node node1, Node node2) protected voidcomplexValueTest(String expr, Complex expected, double tol) Test parse-evaluate with complex number and given tolerance.protected voidmyAssertEquals(String msg, Object expected, Object actual) protected voidmyAssertNaN(String msg, Object actual) protected voidmyAssertNull(String msg, Object actual) protected Objectstatic voidstatic voidstatic voidstatic voidprotected voidprintTestHeader(String str) Prints a header with the name of the test as specified in str.protected voidvoidsetUp()Sets up the parser.voidvoidvoidvoidvoidTest creating a Jep instance with no functions and no variables.voidvoidvoidTest changing variables value after parsingvoidTest changing variables value after parsingvoidvoidvoidvoidvoidvoidvoidTest whether evaluation exceptions are thrown when they should be.voidTests theevaluate()method.voidvoidvoidTests for bug #52voidvoidvoidtestIf()voidvoidvoidvoidTest for bug with 1&&1&&1voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidtestNaN()voidvoidtestNull()voidvoidvoidvoidTests whether a parse exceptions are thrown when they should be.voidvoidvoidvoidTests whether allowUndeclared is working properly.voidvoidvoidtestSpecialFunctions(boolean hasRealEval, boolean hasCallback) voidvoidvoidvoidvoidtestX2Y()protected voidTest values to within a given precisionprotected voidTest result j.evaluate(j.parse(expr))protected voidvalueTestFail(String expr) Test whether evaluating an expression results in an exceptionprotected voidvalueTestNaN(String expr) Test whether an expression evaluates to NaNprotected voidvalueTestNull(String expr) protected voidvalueTestString(String expr, String expected)
-
Field Details
-
PRINT_RESULTS
public static final boolean PRINT_RESULTS- See Also:
-
jep
The parser -
myTrue
-
myFalse
-
-
Constructor Details
-
JepTest
public JepTest()
-
-
Method Details
-
setUp
public void setUp()Sets up the parser. -
printTestHeader
Prints a header with the name of the test as specified in str. -
valueTest
Test result j.evaluate(j.parse(expr))- Parameters:
expr- the expression to parse and evaluateexpected- result expected- Throws:
Exception
-
calcValue
Calculate the value of an expression.- Parameters:
node-- Throws:
Exception
-
calcValue
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
-
myAssertNull
-
valueTestNull
- Throws:
Exception
-
valueTestNaN
Test whether an expression evaluates to NaN- Parameters:
expr-- Throws:
Exception
-
valueTestFail
Test whether evaluating an expression results in an exception- Parameters:
expr-- Throws:
Exception
-
valueTestString
- Throws:
Exception
-
complexValueTest
Test parse-evaluate with complex number and given tolerance.- Parameters:
expr-expected-tol-- Throws:
Exception
-
valueTest
Test values to within a given precision- Parameters:
expr- expressiona- the expected valuetol- tolerance- Throws:
Exception
-
nodeTest
-
nodeTest
-
nodeTest
-
nodeTest
-
compareRecursive
-
assertEqNodes
-
testSimpleSum
- Throws:
Exception
-
testEvaluate
Tests theevaluate()method.- Throws:
Exception
-
test_parser_sets_parent
- Throws:
Exception
-
testEvaluateComplex
- Throws:
Exception
-
testEvaluateString
- Throws:
Exception
-
testChangeVariable
Test changing variables value after parsing- Throws:
Exception
-
testChangeVariableComplex
Test changing variables value after parsing- Throws:
Exception
-
testSetAllowUndeclared
Tests whether allowUndeclared is working properly.- Throws:
Exception
-
negativeZero
-
testNumbers
- Throws:
Exception
-
testStrings
- Throws:
Exception
-
testStringsFun
- Throws:
Exception
-
testNumberAsBooleanLogical
- Throws:
Exception
-
testLogical
- Throws:
Exception
-
testNull
- Throws:
Exception
-
testNaN
- Throws:
Exception
-
testComplex
- Throws:
Exception
-
testFunction
- Throws:
Exception
-
testIf
- Throws:
Exception
-
testPlusPlus
- Throws:
Exception
-
testImplicitMul
- Throws:
Exception
-
testUminusPower
- Throws:
Exception
-
testNumParam
- Throws:
Exception
-
testBinom
- Throws:
Exception
-
testFormat
- Throws:
Exception
-
testAssign
- Throws:
Exception
-
testMultiplyBug
- Throws:
Exception
-
testNoAssign
- Throws:
Exception
-
testLazyLogical
- Throws:
Exception
-
testLazyLogical2
- Throws:
Exception
-
testLazyLogicalBug
Test for bug with 1&&1&&1- Throws:
Exception
-
testLogarithm
- Throws:
Exception
-
testBlankParser
Test creating a Jep instance with no functions and no variables.- Throws:
Exception
-
testMacroFunction
- Throws:
Exception
-
testRecursiveMacroFunction
- 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
- Throws:
Exception
-
testMultiLine
- Throws:
Exception
-
testEmptyEqn
- Throws:
Exception
-
testComments
- Throws:
Exception
-
testEmptyEqn2
- Throws:
Exception
-
test_not_X_Y
- Throws:
Exception
-
testX2Y
- Throws:
Exception
-
testExpectedTokenSequence
public void testExpectedTokenSequence()Tests for bug #52 -
testSwitch
- Throws:
Exception
-
testCaseString
- Throws:
Exception
-
testCaseNull
- Throws:
Exception
-
buildVector
- Throws:
Exception
-
buildMatrix
- Throws:
Exception
-
testComplexListAccess
- Throws:
Exception
-
testListAccess
- Throws:
Exception
-
testListAccessShiftZero
- Throws:
Exception
-
checkVector
- Throws:
EvaluationException
-
testEleUnit
- Throws:
Exception
-
testMultiDimArray
- Throws:
Exception
-
testMultiDimArrayShiftZero
- Throws:
Exception
-
testListFunctions
- Throws:
Exception
-
testListExtra
- Throws:
Exception
-
testSpecialFunctions
- Throws:
Exception
-
testSpecialFunctions
- Throws:
Exception
-
setShiftZeroElePfmc
protected void setShiftZeroElePfmc()
-