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
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertEqNodes
(String s, Node expected, Node actual) protected Object
buildMatrix
(Object[]... eles) protected Object
buildVector
(Object... eles) protected Object
Calculate the value of an expression.protected Object
Calculate the value of an expression.void
checkVector
(Object[] expected, Object actual) protected boolean
compareRecursive
(Node node1, Node node2) protected void
complexValueTest
(String expr, Complex expected, double tol) Test parse-evaluate with complex number and given tolerance.protected void
myAssertEquals
(String msg, Object expected, Object actual) protected void
myAssertNaN
(String msg, Object actual) protected void
myAssertNull
(String msg, Object actual) protected Object
static void
static void
static void
static void
protected void
printTestHeader
(String str) Prints a header with the name of the test as specified in str.protected void
void
setUp()
Sets up the parser.void
void
void
void
void
Test creating a Jep instance with no functions and no variables.void
void
void
Test changing variables value after parsingvoid
Test changing variables value after parsingvoid
void
void
void
void
void
void
Test whether evaluation exceptions are thrown when they should be.void
Tests theevaluate()
method.void
void
void
Tests for bug #52void
void
void
testIf()
void
void
void
void
Test for bug with 1&&1&&1void
void
void
void
void
void
void
void
void
void
void
void
testNaN()
void
void
testNull()
void
void
void
void
Tests whether a parse exceptions are thrown when they should be.void
void
void
void
Tests whether allowUndeclared is working properly.void
void
void
testSpecialFunctions
(boolean hasRealEval, boolean hasCallback) void
void
void
void
void
testX2Y()
protected void
Test values to within a given precisionprotected void
Test result j.evaluate(j.parse(expr))protected void
valueTestFail
(String expr) Test whether evaluating an expression results in an exceptionprotected void
valueTestNaN
(String expr) Test whether an expression evaluates to NaNprotected void
valueTestNull
(String expr) protected void
valueTestString
(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()
-