[jira] [Comment Edited] (JEXL-372) Add support for 'standard' for loop
[ https://issues.apache.org/jira/browse/JEXL-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17558174#comment-17558174 ] Dmitri Blinov edited comment on JEXL-372 at 6/23/22 5:27 PM: - The following test case fails {code:java} @Test public void testForLoop00() { String src = "(l)->{ for(let x = 0, y = 0; x < 4; ++x) { l.add(x); } }"; JexlEngine jexl = new JexlBuilder().safe(true).create(); JexlScript script = jexl.createScript(src); List l = new ArrayList<>(); Object result = script.execute(null, l); Assert.assertNotNull(result); Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l); } {code} While the following test case passes successfully {code:java} @Test public void testForLoop0() { String src = "(l)->{ for(let x = 0; x < 4; ++x) { l.add(x); } }"; JexlEngine jexl = new JexlBuilder().safe(true).create(); JexlScript script = jexl.createScript(src); List l = new ArrayList<>(); Object result = script.execute(null, l); Assert.assertNotNull(result); Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l); } {code} was (Author: dmitri_blinov): The following test case fails {code:java} @Test public void testForLoop00() { String src = "(l)->{ for(let x = 0, y = 0; x < 4; ++x) { l.add(x); } }"; JexlEngine jexl = new JexlBuilder().safe(true).create(); JexlScript script = jexl.createScript(src); List l = new ArrayList<>(); Object result = script.execute(null, l); Assert.assertNotNull(result); Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l); } {code} While following test case passes successfully {code:java} @Test public void testForLoop0() { String src = "(l)->{ for(let x = 0; x < 4; ++x) { l.add(x); } }"; JexlEngine jexl = new JexlBuilder().safe(true).create(); JexlScript script = jexl.createScript(src); List l = new ArrayList<>(); Object result = script.execute(null, l); Assert.assertNotNull(result); Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l); } {code} > Add support for 'standard' for loop > --- > > Key: JEXL-372 > URL: https://issues.apache.org/jira/browse/JEXL-372 > Project: Commons JEXL > Issue Type: Improvement >Affects Versions: 3.2.1 >Reporter: Henri Biestro >Assignee: Henri Biestro >Priority: Major > Fix For: 3.3 > > > It would be nice to allow the C/Javascript/Java for loop: > for(init-expression; predicate-expression; step-expression) body > This calls for the prefix/postfix increment/decrement operators. -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Comment Edited] (JEXL-372) Add support for 'standard' for loop
[ https://issues.apache.org/jira/browse/JEXL-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17553276#comment-17553276 ] Dmitri Blinov edited comment on JEXL-372 at 6/12/22 2:55 PM: - There is also an open question whether default increment/decrement operator arithmetic should trigger overloaded {{\+=}} / {{\-=}} operators, in case those are defined for the incremented/decremented target object. One might expect that ++x should be equal to x += 1 was (Author: dmitri_blinov): There is also an open question whether default increment/decrement operator arithmetic should trigger overloaded += / -+ operators, in case those are defined for the incremented/decremented target object. One might expect that ++x should be equal to x += 1 > Add support for 'standard' for loop > --- > > Key: JEXL-372 > URL: https://issues.apache.org/jira/browse/JEXL-372 > Project: Commons JEXL > Issue Type: Improvement >Affects Versions: 3.2.1 >Reporter: Henri Biestro >Assignee: Henri Biestro >Priority: Major > Fix For: 3.3 > > > It would be nice to allow the C/Javascript/Java for loop: > for(init-expression; predicate-expression; step-expression) body > This calls for the prefix/postfix increment/decrement operators. -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Comment Edited] (JEXL-372) Add support for 'standard' for loop
[ https://issues.apache.org/jira/browse/JEXL-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17553261#comment-17553261 ] Dmitri Blinov edited comment on JEXL-372 at 6/12/22 2:22 PM: - The following use case returns 1 in JS {code:java} @Test public void testIncrementOperatorOnNull() throws Exception { final JexlEngine jexl = new JexlBuilder().strict(false).create(); JexlScript script; Object result; script = jexl.createScript("var i = null; ++i"); result = script.execute(null); Assert.assertEquals(1, result); } {code} May be we should follow suit? was (Author: dmitri_blinov): The following test case returns 1 in JS {code:java} @Test public void testIncrementOperatorOnNull() throws Exception { final JexlEngine jexl = new JexlBuilder().strict(false).create(); JexlScript script; Object result; script = jexl.createScript("var i = null; ++i"); result = script.execute(null); Assert.assertEquals(1, result); } {code} May be we should follow suit? > Add support for 'standard' for loop > --- > > Key: JEXL-372 > URL: https://issues.apache.org/jira/browse/JEXL-372 > Project: Commons JEXL > Issue Type: Improvement >Affects Versions: 3.2.1 >Reporter: Henri Biestro >Assignee: Henri Biestro >Priority: Major > Fix For: 3.3 > > > It would be nice to allow the C/Javascript/Java for loop: > for(init-expression; predicate-expression; step-expression) body > This calls for the prefix/postfix increment/decrement operators. -- This message was sent by Atlassian Jira (v8.20.7#820007)