From 8ee59faa171c3e252d40a3e399822a3f0b41ab06 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 Aug 2025 12:23:18 +0000 Subject: [PATCH 1/4] Initial plan From 89d6f606ec63c2403cacbe17a27c587dbd6c61e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 Aug 2025 12:27:52 +0000 Subject: [PATCH 2/4] Fix BOM character compilation issues in Java source files Co-authored-by: nathanfunk <3503769+nathanfunk@users.noreply.github.com> --- src/main/java/org/lsmp/djep/groupJep/function/GAdd.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/Determinant.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/Diagonal.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/GetDiagonal.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/Id.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/Length.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/MDivide.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/MDot.java | 2 +- src/main/java/org/lsmp/djep/vectorJep/function/MMultiply.java | 2 +- src/main/java/org/nfunk/jep/function/Binomial.java | 2 +- src/main/java/org/nfunk/jep/function/Conjugate.java | 2 +- src/main/java/org/nfunk/jep/function/Ele.java | 2 +- src/main/java/org/nfunk/jep/function/Imaginary.java | 2 +- src/main/java/org/nfunk/jep/function/SquareRoot.java | 2 +- src/main/java/org/nfunk/jep/function/Sum.java | 2 +- src/main/java/org/nfunk/jep/function/UMinus.java | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) 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@ From c470abd32b3f2f6c5ba9765d81ec05d2c3b20536 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 Aug 2025 12:37:00 +0000 Subject: [PATCH 3/4] Add JUnit 5 dependencies and successfully migrate LogarithmTest and NaturalLogarithmTest Co-authored-by: nathanfunk <3503769+nathanfunk@users.noreply.github.com> --- pom.xml | 16 +++ .../java/org/nfunk/jeptesting/AllTests.java | 8 +- .../java/org/nfunk/jeptesting/JEPTest.java | 124 ++++++++++-------- .../org/nfunk/jeptesting/LogarithmTest.java | 17 +-- .../jeptesting/NaturalLogarithmTest.java | 17 +-- 5 files changed, 104 insertions(+), 78 deletions(-) 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/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..01ff07d 100644 --- a/src/test/java/org/nfunk/jeptesting/JEPTest.java +++ b/src/test/java/org/nfunk/jeptesting/JEPTest.java @@ -11,7 +11,11 @@ import java.io.*; -import junit.framework.Assert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +// Keep JUnit 4 imports for backward compatibility during migration import junit.framework.TestCase; import org.nfunk.jep.*; @@ -28,6 +32,9 @@ *
1+2
  *3.
* The expressions '1+2' and '3' are evaluated with JEP and the results compared. + * + * This class extends TestCase for backward compatibility but also uses JUnit 5 annotations + * for new tests during the migration period. */ public class JEPTest extends TestCase { @@ -52,15 +59,23 @@ public JEPTester() { }*/ /** - * Creates a new JEPTest instance + * Creates a new JEPTest instance - for JUnit 4 compatibility */ public JEPTest(String name) { super(name); } /** - * Sets up the parser. + * Default constructor for JUnit 5 + */ + public JEPTest() { + super(); + } + + /** + * Sets up the parser - works for both JUnit 4 and 5 */ + @BeforeEach public void setUp() { // Set up the parser myParser = new JEP(); @@ -75,12 +90,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()); } /** @@ -119,12 +179,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 +296,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(); } } From 380c8322b1a870b697aaa97bc6e9930efad37e06 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 Aug 2025 15:21:56 +0000 Subject: [PATCH 4/4] Fix build issues by completing JEPTest migration to JUnit 5 Co-authored-by: nathanfunk <3503769+nathanfunk@users.noreply.github.com> --- .../java/org/nfunk/jeptesting/JEPTest.java | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/nfunk/jeptesting/JEPTest.java b/src/test/java/org/nfunk/jeptesting/JEPTest.java index 01ff07d..f3eddef 100644 --- a/src/test/java/org/nfunk/jeptesting/JEPTest.java +++ b/src/test/java/org/nfunk/jeptesting/JEPTest.java @@ -15,9 +15,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -// Keep JUnit 4 imports for backward compatibility during migration -import junit.framework.TestCase; - import org.nfunk.jep.*; import org.nfunk.jep.type.Complex; import java.io.InputStream; @@ -33,10 +30,9 @@ *3. * The expressions '1+2' and '3' are evaluated with JEP and the results compared. * - * This class extends TestCase for backward compatibility but also uses JUnit 5 annotations - * for new tests during the migration period. + * This class uses JUnit 5 for testing. */ -public class JEPTest extends TestCase { +public class JEPTest { /** The parser */ JEP myParser; @@ -58,22 +54,15 @@ public JEPTester() { lineCount = 0; }*/ - /** - * Creates a new JEPTest instance - for JUnit 4 compatibility - */ - public JEPTest(String name) { - super(name); - } - /** * Default constructor for JUnit 5 */ public JEPTest() { - super(); + // No need to call super() for Object } /** - * Sets up the parser - works for both JUnit 4 and 5 + * Sets up the parser - works for JUnit 5 */ @BeforeEach public void setUp() { @@ -161,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); }