Package com.singularsys.jeptests.system
Class JepTest
- java.lang.Object
-
- com.singularsys.jeptests.system.JepTest
-
- Direct Known Subclasses:
CPTest,ExtendedParserTest,FieldTest,NullWrapTest,PostfixEvalTest,RpTest,StandardEvaluatorTest,UncheckedEvalTest,XJepDualTest,XJepTest
public class JepTest extends java.lang.ObjectTests various functions on the Jep class. The current implementation tests using the default setup with the JavaCC parser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJepTest.AddFractionsNarystatic classJepTest.AddFractionsStackstatic classJepTest.DiffclassJepTest.MyBinaryclassJepTest.MyNaryclassJepTest.MyNaryBinaryclassJepTest.MyNullaryclassJepTest.MyUnarystatic classJepTest.PiFunstatic classJepTest.Productstatic classJepTest.Square
-
Field Summary
Fields Modifier and Type Field Description protected JepjepThe parserprotected java.lang.ObjectmyFalseprotected java.lang.ObjectmyTruestatic booleanPRINT_RESULTS
-
Constructor Summary
Constructors Constructor Description JepTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertEqNodes(java.lang.String s, Node expected, Node actual)protected java.lang.ObjectbuildMatrix(java.lang.Object[]... eles)protected java.lang.ObjectbuildVector(java.lang.Object... eles)protected java.lang.ObjectcalcValue(Node node)Calculate the value of an expression.protected java.lang.ObjectcalcValue(java.lang.String expr)Calculate the value of an expression.voidcheckVector(java.lang.Object[] expected, java.lang.Object actual)protected booleancompareRecursive(Node node1, Node node2)protected voidcomplexValueTest(java.lang.String expr, Complex expected, double tol)Test parse-evaluate with complex number and given tolerance.protected voidmyAssertEquals(java.lang.String msg, java.lang.Object expected, java.lang.Object actual)protected voidmyAssertNaN(java.lang.String msg, java.lang.Object actual)protected voidmyAssertNull(java.lang.String msg, java.lang.Object actual)protected java.lang.ObjectnegativeZero()static voidnodeTest(Node n, Operator op)static voidnodeTest(Node n, Variable v)static voidnodeTest(Node n, java.lang.Object v)static voidnodeTest(Node n, java.lang.String name)protected voidprintTestHeader(java.lang.String str)Prints a header with the name of the test as specified in str.protected voidsetShiftZeroElePfmc()voidsetUp()Sets up the parser.voidtest_not_X_Y()voidtestAssign()voidtestBinom()voidtestBlankParser()Test creating a Jep instance with no functions and no variables.voidtestCaseNull()voidtestCaseString()voidtestChangeVariable()Test changing variables value after parsingvoidtestChangeVariableComplex()Test changing variables value after parsingvoidtestComments()voidtestComplex()voidtestComplexListAccess()voidtestEleUnit()voidtestEmptyEqn()voidtestEmptyEqn2()voidtestEvalExceptions()Test whether evaluation exceptions are thrown when they should be.voidtestEvaluate()Tests the evaluate() method.voidtestEvaluateComplex()voidtestEvaluateString()voidtestExpectedTokenSequence()Tests for bug #52voidtestFormat()voidtestFunction()voidtestIf()voidtestImplicitMul()voidtestLazyLogical()voidtestLazyLogical2()voidtestLazyLogicalBug()Test for bug with 1&&1&&1voidtestListAccess()voidtestListAccessShiftZero()voidtestListExtra()voidtestListFunctions()voidtestLogarithm()voidtestLogical()voidtestMacroFunction()voidtestMultiDimArray()voidtestMultiDimArrayShiftZero()voidtestMultiLine()voidtestMultiplyBug()voidtestNaN()voidtestNoAssign()voidtestNull()voidtestNumberAsBooleanLogical()voidtestNumbers()voidtestNumParam()voidtestParseException()Tests whether a parse exceptions are thrown when they should be.voidtestPlusPlus()voidtestRecursiveMacroFunction()voidtestSemiColon()voidtestSetAllowUndeclared()Tests whether allowUndeclared is working properly.voidtestSimpleSum()voidtestSpecialFunctions()voidtestSpecialFunctions(boolean hasRealEval, boolean hasCallback)voidtestStrings()voidtestStringsFun()voidtestSwitch()voidtestUminusPower()voidtestX2Y()protected voidvalueTest(java.lang.String expr, double a, double tol)Test values to within a given precisionprotected voidvalueTest(java.lang.String expr, java.lang.Object expected)Test result j.evaluate(j.parse(expr))protected voidvalueTestFail(java.lang.String expr)Test whether evaluating an expression results in an exceptionprotected voidvalueTestNaN(java.lang.String expr)Test whether an expression evaluates to NaNprotected voidvalueTestNull(java.lang.String expr)protected voidvalueTestString(java.lang.String expr, java.lang.String expected)
-
-
-
Field Detail
-
PRINT_RESULTS
public static final boolean PRINT_RESULTS
- See Also:
- Constant Field Values
-
jep
protected Jep jep
The parser
-
myTrue
protected java.lang.Object myTrue
-
myFalse
protected java.lang.Object myFalse
-
-
Method Detail
-
setUp
public void setUp()
Sets up the parser.
-
printTestHeader
protected void printTestHeader(java.lang.String str)
Prints a header with the name of the test as specified in str.
-
valueTest
protected void valueTest(java.lang.String expr, java.lang.Object expected) throws java.lang.ExceptionTest result j.evaluate(j.parse(expr))- Parameters:
expr- the expression to parse and evaluateexpected- result expected- Throws:
java.lang.Exception
-
calcValue
protected java.lang.Object calcValue(Node node) throws java.lang.Exception
Calculate the value of an expression.- Parameters:
node-- Throws:
java.lang.Exception
-
calcValue
protected java.lang.Object calcValue(java.lang.String expr) throws java.lang.ExceptionCalculate the value of an expression.- Parameters:
expr-- Throws:
java.lang.Exception
-
myAssertEquals
protected void myAssertEquals(java.lang.String msg, java.lang.Object expected, java.lang.Object actual) throws EvaluationException- Throws:
EvaluationException
-
myAssertNaN
protected void myAssertNaN(java.lang.String msg, java.lang.Object actual)
-
myAssertNull
protected void myAssertNull(java.lang.String msg, java.lang.Object actual)
-
valueTestNull
protected void valueTestNull(java.lang.String expr) throws java.lang.Exception- Throws:
java.lang.Exception
-
valueTestNaN
protected void valueTestNaN(java.lang.String expr) throws java.lang.ExceptionTest whether an expression evaluates to NaN- Parameters:
expr-- Throws:
java.lang.Exception
-
valueTestFail
protected void valueTestFail(java.lang.String expr) throws java.lang.ExceptionTest whether evaluating an expression results in an exception- Parameters:
expr-- Throws:
java.lang.Exception
-
valueTestString
protected void valueTestString(java.lang.String expr, java.lang.String expected) throws java.lang.Exception- Throws:
java.lang.Exception
-
complexValueTest
protected void complexValueTest(java.lang.String expr, Complex expected, double tol) throws java.lang.ExceptionTest parse-evaluate with complex number and given tolerance.- Parameters:
expr-expected-tol-- Throws:
java.lang.Exception
-
valueTest
protected void valueTest(java.lang.String expr, double a, double tol) throws java.lang.ExceptionTest values to within a given precision- Parameters:
expr- expressiona- the expected valuetol- tolerance- Throws:
java.lang.Exception
-
nodeTest
public static void nodeTest(Node n, java.lang.String name)
-
nodeTest
public static void nodeTest(Node n, java.lang.Object v)
-
testSimpleSum
public void testSimpleSum() throws java.lang.Exception- Throws:
java.lang.Exception
-
testEvaluate
public void testEvaluate() throws java.lang.ExceptionTests the evaluate() method.- Throws:
java.lang.Exception
-
testEvaluateComplex
public void testEvaluateComplex() throws java.lang.Exception- Throws:
java.lang.Exception
-
testEvaluateString
public void testEvaluateString() throws java.lang.Exception- Throws:
java.lang.Exception
-
testChangeVariable
public void testChangeVariable() throws java.lang.ExceptionTest changing variables value after parsing- Throws:
java.lang.Exception
-
testChangeVariableComplex
public void testChangeVariableComplex() throws java.lang.ExceptionTest changing variables value after parsing- Throws:
java.lang.Exception
-
testSetAllowUndeclared
public void testSetAllowUndeclared() throws java.lang.ExceptionTests whether allowUndeclared is working properly.- Throws:
java.lang.Exception
-
negativeZero
protected java.lang.Object negativeZero()
-
testNumbers
public void testNumbers() throws java.lang.Exception- Throws:
java.lang.Exception
-
testStrings
public void testStrings() throws java.lang.Exception- Throws:
java.lang.Exception
-
testStringsFun
public void testStringsFun() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNumberAsBooleanLogical
public void testNumberAsBooleanLogical() throws java.lang.Exception- Throws:
java.lang.Exception
-
testLogical
public void testLogical() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNull
public void testNull() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNaN
public void testNaN() throws java.lang.Exception- Throws:
java.lang.Exception
-
testComplex
public void testComplex() throws java.lang.Exception- Throws:
java.lang.Exception
-
testFunction
public void testFunction() throws java.lang.Exception- Throws:
java.lang.Exception
-
testIf
public void testIf() throws java.lang.Exception- Throws:
java.lang.Exception
-
testPlusPlus
public void testPlusPlus() throws java.lang.Exception- Throws:
java.lang.Exception
-
testImplicitMul
public void testImplicitMul() throws java.lang.Exception- Throws:
java.lang.Exception
-
testUminusPower
public void testUminusPower() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNumParam
public void testNumParam() throws java.lang.Exception- Throws:
java.lang.Exception
-
testBinom
public void testBinom() throws ParseException, java.lang.Exception- Throws:
ParseExceptionjava.lang.Exception
-
testFormat
public void testFormat() throws java.lang.Exception- Throws:
java.lang.Exception
-
testAssign
public void testAssign() throws java.lang.Exception- Throws:
java.lang.Exception
-
testMultiplyBug
public void testMultiplyBug() throws java.lang.Exception- Throws:
java.lang.Exception
-
testNoAssign
public void testNoAssign() throws java.lang.Exception- Throws:
java.lang.Exception
-
testLazyLogical
public void testLazyLogical() throws java.lang.Exception- Throws:
java.lang.Exception
-
testLazyLogical2
public void testLazyLogical2() throws java.lang.Exception- Throws:
java.lang.Exception
-
testLazyLogicalBug
public void testLazyLogicalBug() throws java.lang.ExceptionTest for bug with 1&&1&&1- Throws:
java.lang.Exception
-
testLogarithm
public void testLogarithm() throws java.lang.Exception- Throws:
java.lang.Exception
-
testBlankParser
public void testBlankParser() throws java.lang.ExceptionTest creating a Jep instance with no functions and no variables.- Throws:
java.lang.Exception
-
testMacroFunction
public void testMacroFunction() throws java.lang.Exception- Throws:
java.lang.Exception
-
testRecursiveMacroFunction
public void testRecursiveMacroFunction() throws java.lang.Exception- Throws:
java.lang.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 java.lang.Exception- Throws:
java.lang.Exception
-
testMultiLine
public void testMultiLine() throws java.lang.Exception- Throws:
java.lang.Exception
-
testEmptyEqn
public void testEmptyEqn() throws java.lang.Exception- Throws:
java.lang.Exception
-
testComments
public void testComments() throws java.lang.Exception- Throws:
java.lang.Exception
-
testEmptyEqn2
public void testEmptyEqn2() throws java.lang.Exception- Throws:
java.lang.Exception
-
test_not_X_Y
public void test_not_X_Y() throws java.lang.Exception- Throws:
java.lang.Exception
-
testX2Y
public void testX2Y() throws java.lang.Exception- Throws:
java.lang.Exception
-
testExpectedTokenSequence
public void testExpectedTokenSequence()
Tests for bug #52
-
testSwitch
public void testSwitch() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCaseString
public void testCaseString() throws java.lang.Exception- Throws:
java.lang.Exception
-
testCaseNull
public void testCaseNull() throws java.lang.Exception- Throws:
java.lang.Exception
-
buildVector
protected java.lang.Object buildVector(java.lang.Object... eles) throws java.lang.Exception- Throws:
java.lang.Exception
-
buildMatrix
protected java.lang.Object buildMatrix(java.lang.Object[]... eles) throws java.lang.Exception- Throws:
java.lang.Exception
-
testComplexListAccess
public void testComplexListAccess() throws java.lang.Exception- Throws:
java.lang.Exception
-
testListAccess
public void testListAccess() throws java.lang.Exception- Throws:
java.lang.Exception
-
testListAccessShiftZero
public void testListAccessShiftZero() throws java.lang.Exception- Throws:
java.lang.Exception
-
checkVector
public void checkVector(java.lang.Object[] expected, java.lang.Object actual) throws EvaluationException- Throws:
EvaluationException
-
testEleUnit
public void testEleUnit() throws java.lang.Exception- Throws:
java.lang.Exception
-
testMultiDimArray
public void testMultiDimArray() throws java.lang.Exception- Throws:
java.lang.Exception
-
testMultiDimArrayShiftZero
public void testMultiDimArrayShiftZero() throws java.lang.Exception- Throws:
java.lang.Exception
-
testListFunctions
public void testListFunctions() throws java.lang.Exception- Throws:
java.lang.Exception
-
testListExtra
public void testListExtra() throws java.lang.Exception- Throws:
java.lang.Exception
-
testSpecialFunctions
public void testSpecialFunctions() throws java.lang.Exception- Throws:
java.lang.Exception
-
testSpecialFunctions
public void testSpecialFunctions(boolean hasRealEval, boolean hasCallback) throws java.lang.Exception- Throws:
java.lang.Exception
-
setShiftZeroElePfmc
protected void setShiftZeroElePfmc()
-
-