[ 
https://issues.apache.org/jira/browse/JEXL-270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16597351#comment-16597351
 ] 

Dmitri Blinov commented on JEXL-270:
------------------------------------

I figured out that the problem was with two methods of {{internal/Script.java}}

the second argument {{false}} should be added to the {{debug.debug(script)}} 
call
{code:java}
    @Override
    public String getParsedText(int indent) {
        Debugger debug = new Debugger();
        debug.setIndentation(indent);
        debug.debug(script, false);
        return debug.toString();
    }

    @Override
    public String toString() {
        CharSequence src = source;
        if (src == null) {
            Debugger debug = new Debugger();
            debug.debug(script, false);
            src = debug.toString();
        }
        return src.toString();
    }
{code}

Can we apply the patch to the source tree?

> Wrong Script$Curried creation when script.curry() method is called inside 
> script
> --------------------------------------------------------------------------------
>
>                 Key: JEXL-270
>                 URL: https://issues.apache.org/jira/browse/JEXL-270
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: Dmitri Blinov
>            Priority: Major
>
> I have noticed that when i call lambda.curry() method inside the script, then 
> the curried lamba is created with wrong source text. I expect the source text 
> of the curried lambda to be always equal to that of original, but that is not 
> the case now. To illustrate this I have prepared two testcases, from which 
> {{testCurryScript2}} fails with 
> [ERROR] Failures:
> [ERROR]   LambdaTest.testCurryScript2:307 expected:<true> but was:<false>
> {code:java}
>     @Test
>     public void testCurryScript() throws Exception {
>         JexlEngine jexl = new Engine();
>         JexlScript base = jexl.createScript("(x, y, z)->{ x + y + z }");
>         String text = base.toString();
>         JexlScript script = base.curry(5, 15);
>         Assert.assertEquals(text, script.toString());
>         JexlEvalContext ctxt = new JexlEvalContext();
>         ctxt.set("s", base);
>         script = jexl.createScript("return s");
>         Object result = script.execute(ctxt);
>         Assert.assertEquals(text, result.toString());
>         script = jexl.createScript("return s.curry(1)");
>         result = script.execute(ctxt);
>         Assert.assertEquals(text, result.toString());
>     }
>     @Test
>     public void testCurryScript2() throws Exception {
>         JexlEngine jexl = new Engine();
>         JexlScript base = jexl.createScript("var base = 0; var sum = (y, z) 
> -> {var x = base; x += y; return x}; base = 2; var y = sum.curry(1); 
> y.toString() eq sum.toString()");
>         Object result = base.execute(null);
>         Assert.assertEquals(Boolean.TRUE, result);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to