diff --git a/pom.xml b/pom.xml
index 347a7a2..b29998b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,22 @@
test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.11.1
+ test
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.11.1
+ test
+
+
org.junit.vintage
diff --git a/src/main/java/org/lsmp/djep/groupJep/function/GAdd.java b/src/main/java/org/lsmp/djep/groupJep/function/GAdd.java
index bc50264..b1ddf7b 100644
--- a/src/main/java/org/lsmp/djep/groupJep/function/GAdd.java
+++ b/src/main/java/org/lsmp/djep/groupJep/function/GAdd.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 05-Mar-2004
*/
package org.lsmp.djep.groupJep.function;
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/Determinant.java b/src/main/java/org/lsmp/djep/vectorJep/function/Determinant.java
index 620221b..f6f6053 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/Determinant.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/Determinant.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 13-Feb-2005
*
* See LICENSE.txt for license information.
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/Diagonal.java b/src/main/java/org/lsmp/djep/vectorJep/function/Diagonal.java
index 1d9789e..2c7587e 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/Diagonal.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/Diagonal.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 13-Feb-2005
*
* See LICENSE.txt for license information.
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/GetDiagonal.java b/src/main/java/org/lsmp/djep/vectorJep/function/GetDiagonal.java
index a9afbca..4e58ce8 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/GetDiagonal.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/GetDiagonal.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 13-Feb-2005
*
* See LICENSE.txt for license information.
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/Id.java b/src/main/java/org/lsmp/djep/vectorJep/function/Id.java
index 71ea555..d42636f 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/Id.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/Id.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 13-Feb-2005
*
* See LICENSE.txt for license information.
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/Length.java b/src/main/java/org/lsmp/djep/vectorJep/function/Length.java
index 767a385..4fe33d3 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/Length.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/Length.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 13-Feb-2005
*
* See LICENSE.txt for license information.
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/MDivide.java b/src/main/java/org/lsmp/djep/vectorJep/function/MDivide.java
index c255bd5..1cf503f 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/MDivide.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/MDivide.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 27-Jul-2003
*/
package org.lsmp.djep.vectorJep.function;
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/MDot.java b/src/main/java/org/lsmp/djep/vectorJep/function/MDot.java
index c817a37..2ecaee9 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/MDot.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/MDot.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/*****************************************************************************
JEP - Java Math Expression Parser 2.24
December 30 2002
diff --git a/src/main/java/org/lsmp/djep/vectorJep/function/MMultiply.java b/src/main/java/org/lsmp/djep/vectorJep/function/MMultiply.java
index d197b0d..6b63ade 100644
--- a/src/main/java/org/lsmp/djep/vectorJep/function/MMultiply.java
+++ b/src/main/java/org/lsmp/djep/vectorJep/function/MMultiply.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 27-Jul-2003
*/
package org.lsmp.djep.vectorJep.function;
diff --git a/src/main/java/org/nfunk/jep/function/Binomial.java b/src/main/java/org/nfunk/jep/function/Binomial.java
index 35c0a84..72a6aad 100644
--- a/src/main/java/org/nfunk/jep/function/Binomial.java
+++ b/src/main/java/org/nfunk/jep/function/Binomial.java
@@ -1,4 +1,4 @@
-/* @author rich
+/* @author rich
* Created on 13-Feb-2005
*
* See LICENSE.txt for license information.
diff --git a/src/main/java/org/nfunk/jep/function/Conjugate.java b/src/main/java/org/nfunk/jep/function/Conjugate.java
index f6d5a8d..9770751 100644
--- a/src/main/java/org/nfunk/jep/function/Conjugate.java
+++ b/src/main/java/org/nfunk/jep/function/Conjugate.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/*****************************************************************************
@header@
@date@
diff --git a/src/main/java/org/nfunk/jep/function/Ele.java b/src/main/java/org/nfunk/jep/function/Ele.java
index 1f071d1..991daf7 100644
--- a/src/main/java/org/nfunk/jep/function/Ele.java
+++ b/src/main/java/org/nfunk/jep/function/Ele.java
@@ -1,4 +1,4 @@
-/*
+/*
Created 26-May-2006 - Richard Morris
*/
package org.nfunk.jep.function;
diff --git a/src/main/java/org/nfunk/jep/function/Imaginary.java b/src/main/java/org/nfunk/jep/function/Imaginary.java
index 2717fb7..dd8de0c 100644
--- a/src/main/java/org/nfunk/jep/function/Imaginary.java
+++ b/src/main/java/org/nfunk/jep/function/Imaginary.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/*****************************************************************************
@header@
@date@
diff --git a/src/main/java/org/nfunk/jep/function/SquareRoot.java b/src/main/java/org/nfunk/jep/function/SquareRoot.java
index 00f0df1..0f82d37 100644
--- a/src/main/java/org/nfunk/jep/function/SquareRoot.java
+++ b/src/main/java/org/nfunk/jep/function/SquareRoot.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/*****************************************************************************
@header@
@date@
diff --git a/src/main/java/org/nfunk/jep/function/Sum.java b/src/main/java/org/nfunk/jep/function/Sum.java
index b5d0672..4890ff3 100644
--- a/src/main/java/org/nfunk/jep/function/Sum.java
+++ b/src/main/java/org/nfunk/jep/function/Sum.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/*****************************************************************************
@header@
@date@
diff --git a/src/main/java/org/nfunk/jep/function/UMinus.java b/src/main/java/org/nfunk/jep/function/UMinus.java
index cd5d761..ce7bd94 100644
--- a/src/main/java/org/nfunk/jep/function/UMinus.java
+++ b/src/main/java/org/nfunk/jep/function/UMinus.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/*****************************************************************************
@header@
@date@
diff --git a/src/test/java/org/nfunk/jeptesting/AllTests.java b/src/test/java/org/nfunk/jeptesting/AllTests.java
index 1fc2cc0..9638388 100644
--- a/src/test/java/org/nfunk/jeptesting/AllTests.java
+++ b/src/test/java/org/nfunk/jeptesting/AllTests.java
@@ -19,9 +19,11 @@ public static void main (String[] args) {
public static Test suite() {
TestSuite suite = new TestSuite("All JUnit Tests");
- suite.addTest(new JEPTest("testParseExpression"));
- suite.addTest(new LogarithmTest("testLogarithm"));
- suite.addTest(new NaturalLogarithmTest("testNaturalLogarithm"));
+ // TODO: Update these when JEPTest is fully migrated to JUnit 5
+ // For now, these tests will run directly via JUnit 5 discovery
+ // suite.addTest(new JEPTest("testParseExpression"));
+ // suite.addTest(new LogarithmTest("testLogarithm"));
+ // suite.addTest(new NaturalLogarithmTest("testNaturalLogarithm"));
return suite;
}
}
diff --git a/src/test/java/org/nfunk/jeptesting/JEPTest.java b/src/test/java/org/nfunk/jeptesting/JEPTest.java
index f1093d3..f3eddef 100644
--- a/src/test/java/org/nfunk/jeptesting/JEPTest.java
+++ b/src/test/java/org/nfunk/jeptesting/JEPTest.java
@@ -11,8 +11,9 @@
import java.io.*;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.nfunk.jep.*;
import org.nfunk.jep.type.Complex;
@@ -28,8 +29,10 @@
* 1+2
*3.
* The expressions '1+2' and '3' are evaluated with JEP and the results compared.
+ *
+ * This class uses JUnit 5 for testing.
*/
-public class JEPTest extends TestCase {
+public class JEPTest {
/** The parser */
JEP myParser;
@@ -52,15 +55,16 @@ public JEPTester() {
}*/
/**
- * Creates a new JEPTest instance
+ * Default constructor for JUnit 5
*/
- public JEPTest(String name) {
- super(name);
+ public JEPTest() {
+ // No need to call super() for Object
}
/**
- * Sets up the parser.
+ * Sets up the parser - works for JUnit 5
*/
+ @BeforeEach
public void setUp() {
// Set up the parser
myParser = new JEP();
@@ -75,12 +79,57 @@ public void setUp() {
/**
* Runs the test.
*/
- public void runTest() {
+ @Test
+ public void testExpressionFile() {
String fileName = "JEPTestExpressions.txt";
testWithFile(fileName);
- testGetValue();
- testGetComplexValue();
- testOpSetBug();
+ }
+
+ @Test
+ public void testGetValue() {
+ // Test whether a normal double value is returned correctly
+ myParser.parseExpression("2.1345");
+ Assertions.assertEquals(myParser.getValue(), 2.1345, 0);
+
+ // Test whether NaN is returned for Complex numbers
+ myParser.parseExpression("i");
+ Assertions.assertTrue(Double.isNaN(myParser.getValue()));
+
+ // Test whether NaN is returned for String results
+ myParser.parseExpression("\"asdf\"");
+ Assertions.assertTrue(Double.isNaN(myParser.getValue()));
+ }
+
+ @Test
+ public void testGetComplexValue() {
+ // Test whether a normal double value is returned as a Complex
+ myParser.parseExpression("2.1345");
+ Assertions.assertTrue(new Complex(2.1345, 0).equals(
+ myParser.getComplexValue(), 0));
+
+ // Test whether (0, 1) is returned for i
+ myParser.parseExpression("i");
+ Complex z = myParser.getComplexValue();
+ Assertions.assertNotNull(z);
+ Assertions.assertEquals(0, z.re());
+ Assertions.assertEquals(1, z.im());
+
+ // Test whether NaN is returned for String results
+ myParser.parseExpression("\"asdf\"");
+ Assertions.assertTrue(Double.isNaN(myParser.getValue()));
+ }
+
+ /**
+ * Backwards compatibility method for old test suite
+ */
+ public void testParseExpression() {
+ testExpressionFile();
+ }
+
+ @Test
+ public void testOpSetBug() {
+ JEP j = new JEP(false, true, true, null);
+ Assertions.assertNotNull(j.getOperatorSet());
}
/**
@@ -101,7 +150,7 @@ public static void main(String args[]) {
}
// Create an instance of this class and analyse the file
- JEPTest jt = new JEPTest("JEP Test");
+ JEPTest jt = new JEPTest();
jt.setUp();
jt.testWithFile(fileName);
}
@@ -119,12 +168,12 @@ public void testWithFile(String fileName) {
try {
InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);
if (is == null) {
- Assert.fail("File \""+fileName+"\" not found in resources");
+ Assertions.fail("File \""+fileName+"\" not found in resources");
return;
}
reader = new BufferedReader(new InputStreamReader(is));
} catch (Exception e) {
- Assert.fail("Error reading file: " + e.getMessage());
+ Assertions.fail("Error reading file: " + e.getMessage());
return;
}
@@ -236,52 +285,6 @@ private boolean equal(Object param1, Object param2) throws Exception
// throw new Exception("Unable to compare the values of this type");
}
- /**
- * Test the getValue() method.
- */
- public void testGetValue() {
- // Test whether a normal double value is returned correctly
- myParser.parseExpression("2.1345");
- Assert.assertEquals(myParser.getValue(), 2.1345, 0);
-
- // Test whether NaN is returned for Somplex numbers
- myParser.parseExpression("i");
- Assert.assertTrue(Double.isNaN(myParser.getValue()));
-
- // Test whether NaN is returned for String results
- myParser.parseExpression("\"asdf\"");
- Assert.assertTrue(Double.isNaN(myParser.getValue()));
- }
-
- /**
- * Test the getComplexValue() method.
- */
- public void testGetComplexValue() {
- // Test whether a normal double value is returned as a Complex
- myParser.parseExpression("2.1345");
- Assert.assertTrue(new Complex(2.1345, 0).equals(
- myParser.getComplexValue(), 0));
-
- // Test whether (0, 1) is returned for i
- myParser.parseExpression("i");
- Complex z = myParser.getComplexValue();
- Assert.assertTrue(z != null);
- Assert.assertTrue(z.re() == 0);
- Assert.assertTrue(z.im() == 1);
-
- // Test whether NaN is returned for String results
- myParser.parseExpression("\"asdf\"");
- Assert.assertTrue(Double.isNaN(myParser.getValue()));
- }
-
- /**
- * Tests the uninitialized OperatorSet bug 1061200
- */
- public void testOpSetBug() {
- JEP j = new JEP(false, true, true, null);
- Assert.assertNotNull(j.getOperatorSet());
- }
-
/**
* Helper function for printing.
*/
diff --git a/src/test/java/org/nfunk/jeptesting/LogarithmTest.java b/src/test/java/org/nfunk/jeptesting/LogarithmTest.java
index dc6af83..745296d 100644
--- a/src/test/java/org/nfunk/jeptesting/LogarithmTest.java
+++ b/src/test/java/org/nfunk/jeptesting/LogarithmTest.java
@@ -3,19 +3,16 @@
import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.Logarithm;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
-public class LogarithmTest extends TestCase {
-
- public LogarithmTest(String name) {
- super(name);
- }
+public class LogarithmTest {
/**
* Test method for 'org.nfunk.jep.function.Logarithm.run(Stack)'
* Tests the return value of log(NaN). This is a test for bug #1177557
*/
+ @Test
public void testLogarithm() {
Logarithm logFunction = new Logarithm();
java.util.Stack stack = new java.util.Stack();
@@ -23,14 +20,14 @@ public void testLogarithm() {
try {
logFunction.run(stack);
} catch (ParseException e) {
- Assert.fail();
+ Assertions.fail();
}
Object returnValue = stack.pop();
if (returnValue instanceof Double) {
- Assert.assertTrue(Double.isNaN(((Double)returnValue).doubleValue()));
+ Assertions.assertTrue(Double.isNaN(((Double)returnValue).doubleValue()));
} else {
- Assert.fail();
+ Assertions.fail();
}
}
diff --git a/src/test/java/org/nfunk/jeptesting/NaturalLogarithmTest.java b/src/test/java/org/nfunk/jeptesting/NaturalLogarithmTest.java
index 7c44475..cb4701e 100644
--- a/src/test/java/org/nfunk/jeptesting/NaturalLogarithmTest.java
+++ b/src/test/java/org/nfunk/jeptesting/NaturalLogarithmTest.java
@@ -3,20 +3,17 @@
import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.NaturalLogarithm;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
@SuppressWarnings({"rawtypes","unchecked"})
-public class NaturalLogarithmTest extends TestCase {
-
- public NaturalLogarithmTest(String name) {
- super(name);
- }
+public class NaturalLogarithmTest {
/**
* Test method for 'org.nfunk.jep.function.Logarithm.run(Stack)'
* Tests the return value of log(NaN). This is a test for bug #1177557
*/
+ @Test
public void testNaturalLogarithm() {
NaturalLogarithm logFunction = new NaturalLogarithm();
java.util.Stack stack = new java.util.Stack();
@@ -24,14 +21,14 @@ public void testNaturalLogarithm() {
try {
logFunction.run(stack);
} catch (ParseException e) {
- Assert.fail();
+ Assertions.fail();
}
Object returnValue = stack.pop();
if (returnValue instanceof Double) {
- Assert.assertTrue(Double.isNaN(((Double)returnValue).doubleValue()));
+ Assertions.assertTrue(Double.isNaN(((Double)returnValue).doubleValue()));
} else {
- Assert.fail();
+ Assertions.fail();
}
}