Package com.singularsys.jeptests.system
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
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNaryFunction to add fractionsstatic classFunction to add fractions using a stackstatic classFunction for diference of two variables.protected static classA binary functionprotected static classAn Nary functionprotected static classAn NaryBinary functionprotected static classA nullary functionsprotected static classA unary functionstatic classReal nullay functionstatic classProduct of valuesstatic classSquare of value -
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 ObjectCreate a number of the appropriate typeprotected 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.voidvoidvoidvoidvoidvoidTest 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&&1voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidtestNaN()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 -
jep
The parser -
myTrue
-
myFalse
-
-
Constructor Details
-
JepTest
public JepTest()
-
-
Method Details
-
setUp
@BeforeEach 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:
JepException
-
calcValue
Calculate the value of an expression.- Parameters:
node-- Throws:
JepException
-
getNumber
Create a number of the appropriate type- Parameters:
val- input- Returns:
- converted number
-
negativeZero
-
calcValue
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
-
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
-
testNumbers
- Throws:
Exception
-
testStrings
- Throws:
Exception
-
testStringsFun
- Throws:
Exception
-
testNumberAsBooleanLogical
- Throws:
Exception
-
test_adding_existing_constant_fails
- 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
@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
- Throws:
Exception
-
testMultiLine
- Throws:
Exception
-
testEmptyEqn
- Throws:
Exception
-
testComments
- Throws:
Exception
-
testEmptyEqn2
- Throws:
Exception
-
test_not_X_Y
- Throws:
Exception
-
testX2Y
- Throws:
Exception
-
testExpectedTokenSequence
@Test 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
-
testListOperations
- 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()
-