zguokai / aviator

Automatically exported from code.google.com/p/aviator
0 stars 0 forks source link

When using ScriptEngine to eval script, have not using correct scope variable. #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. When using ScriptEngine to eval script, have not using correct scope 
variable.

What is the expected output? What do you see instead?
The next code can't run successful.
public class AviatorTest {

    private ScriptEngineManager manager = new ScriptEngineManager();
    private ScriptEngine engine = manager.getEngineByName("Aviator");

    @Test
    public void testGlobal2VarScope() throws ScriptException {
        String script = "greeting";
        Object eval;

        // ScriptEngineManager scope
        manager.put("greeting", "ScriptEngineManager scope");
        eval = engine.eval(script);
        assertEquals("ScriptEngineManager scope", eval);

        // ScriptEngine scope
        engine.put("greeting", "ScriptEngine scope");
        eval = engine.eval(script);
        assertEquals("ScriptEngine scope", eval);

        // Bindings scope
        Bindings bindings = engine.createBindings();
        bindings.put("greeting", "Bindings scope");
        eval = engine.eval(script, bindings);
        assertEquals("Bindings scope", eval);
    }
}

What version of the product are you using? On what operating system?
Version: aviator 2.2.1
JDK: 1.6.0_23
OS: Windows xp

Please provide any additional information below.

Original issue reported on code.google.com by bul...@gmail.com on 10 Mar 2012 at 11:55

GoogleCodeExporter commented 8 years ago
Yes,it's an issue,i will fix it,thanks for your report.

Original comment by killme2...@gmail.com on 16 Mar 2012 at 3:07