This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push: new 57b6a5a4 JEXL-360: missed a few test cases; - opportunistic fix of '%=' not being controlled for side-effects; 57b6a5a4 is described below commit 57b6a5a4b6db0fe9f75b7ef73dabaf60bd09d17f Author: henrib <hen...@apache.org> AuthorDate: Mon May 9 11:20:18 2022 +0200 JEXL-360: missed a few test cases; - opportunistic fix of '%=' not being controlled for side-effects; --- .../org/apache/commons/jexl3/parser/FeatureController.java | 5 +++++ src/test/java/org/apache/commons/jexl3/FeaturesTest.java | 4 ++++ .../java/org/apache/commons/jexl3/ShiftOperatorsTest.java | 12 ++++++++---- src/test/java/org/apache/commons/jexl3/SideEffectTest.java | 12 ++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java b/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java index 23e290b0..b6487db6 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java +++ b/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java @@ -214,6 +214,11 @@ public class FeatureController extends ScriptVisitor { return controlSideEffect(node, data); } + @Override + protected Object visit(final ASTSetModNode node, final Object data) { + return controlSideEffect(node, data); + } + @Override protected Object visit(final ASTSetAndNode node, final Object data) { return controlSideEffect(node, data); diff --git a/src/test/java/org/apache/commons/jexl3/FeaturesTest.java b/src/test/java/org/apache/commons/jexl3/FeaturesTest.java index edaa2b73..6893b46f 100644 --- a/src/test/java/org/apache/commons/jexl3/FeaturesTest.java +++ b/src/test/java/org/apache/commons/jexl3/FeaturesTest.java @@ -125,9 +125,13 @@ public class FeaturesTest extends JexlTestCase { "x -= 1", "x *= 1", "x /= 1", + "x %= 1", "x ^= 1", "x &= 1", "x |= 1", + "x >>= 1", + "x <<= 1", + "x >>>= 1", }; checkFeature(f, scripts); } diff --git a/src/test/java/org/apache/commons/jexl3/ShiftOperatorsTest.java b/src/test/java/org/apache/commons/jexl3/ShiftOperatorsTest.java index 2bff54d3..d9e0a262 100644 --- a/src/test/java/org/apache/commons/jexl3/ShiftOperatorsTest.java +++ b/src/test/java/org/apache/commons/jexl3/ShiftOperatorsTest.java @@ -151,10 +151,14 @@ public class ShiftOperatorsTest extends JexlTestCase { @Test public void testOverloadedShift() throws Exception { JexlEngine jexl = new JexlBuilder().arithmetic(new ShiftArithmetic(true)).create(); - JexlScript e = jexl.createScript("x << 'Left'", "x"); - StringBuilder x = new StringBuilder("1"); - Object o = e.execute(null, x); - Assert.assertEquals(e.getSourceText(), "1Left", x.toString()); + StringBuilder x; + JexlScript e; + Object o; + + x = new StringBuilder("1"); + e = jexl.createScript("x << 'Left'", "x"); + o = e.execute(null, x); + Assert.assertEquals(e.getSourceText(), "1Left", o.toString()); e = jexl.createScript("'Right' >> x", "x"); x = new StringBuilder("1"); diff --git a/src/test/java/org/apache/commons/jexl3/SideEffectTest.java b/src/test/java/org/apache/commons/jexl3/SideEffectTest.java index c258b7d9..a198165a 100644 --- a/src/test/java/org/apache/commons/jexl3/SideEffectTest.java +++ b/src/test/java/org/apache/commons/jexl3/SideEffectTest.java @@ -89,6 +89,18 @@ public class SideEffectTest extends JexlTestCase { context.put("foo", foo); asserter.assertExpression("foo ^= 2", (long)(i41 ^ 2)); Assert.assertEquals(context.get("foo"), (long)(i41 ^ 2)); + + context.put("foo", foo); + asserter.assertExpression("foo <<= 2", (long)(i41 << 2)); + Assert.assertEquals(context.get("foo"), (long)(i41 << 2)); + + context.put("foo", foo); + asserter.assertExpression("foo >>= 2", (long)(i41 >> 2)); + Assert.assertEquals(context.get("foo"), (long)(i41 >> 2)); + + context.put("foo", foo); + asserter.assertExpression("foo >>>= 2", (long)(i41 >>> 2)); + Assert.assertEquals(context.get("foo"), (long)(i41 >>> 2)); } @Test