

package jdk.nashorn.api.scripting;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.testng.annotations.Test;

/**
 * Test that we can create multiple, independent script engines and use those
 * independently.
 *
 * @test
 * @run testng jdk.nashorn.api.scripting.MultipleEngineTest
 */

public class MultipleEngineTest {
    @Test
    public void createAndUseManyEngine() throws ScriptException {
        final ScriptEngineManager m = new ScriptEngineManager();

        final ScriptEngine e1 = m.getEngineByName("nashorn");
        e1.eval("var  x = 33; print(x);");

        final ScriptEngine e2 = m.getEngineByName("nashorn");
        e2.eval("try { print(x) } catch(e) { print(e); }");
    }
}
