[
https://issues.apache.org/jira/browse/JEXL-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17558174#comment-17558174
]
Dmitri Blinov commented on JEXL-372:
------------------------------------
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<Integer> 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<Integer> 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)