use of javax.script.ScriptEngineManager in project hazelcast by hazelcast.
the class HazelcastOSGiScriptEngineTest method bindingsGetAndSetSuccessfully.
@Test
public void bindingsGetAndSetSuccessfully() {
ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
List<ScriptEngineFactory> engineFactories = scriptEngineManager.getEngineFactories();
assertNotNull(engineFactories);
for (ScriptEngineFactory engineFactory : engineFactories) {
verifyThatBindingsGetAndSetSuccessfully(engineFactory.getScriptEngine());
}
}
use of javax.script.ScriptEngineManager in project groovy-core by groovy.
the class JSR223SpecTest method testInvocableFunction.
@Test
public void testInvocableFunction() throws ScriptException, NoSuchMethodException {
// tag::jsr223_invocable[]
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("groovy");
String fact = "def factorial(n) { n == 1 ? 1 : n * factorial(n - 1) }";
engine.eval(fact);
Invocable inv = (Invocable) engine;
Object[] params = { 5 };
Object result = inv.invokeFunction("factorial", params);
assertEquals(new Integer(120), result);
// end::jsr223_invocable[]
}
use of javax.script.ScriptEngineManager in project groovy-core by groovy.
the class JSR223SpecTest method testSimpleExample.
@Test
public void testSimpleExample() throws ScriptException {
// tag::jsr223_init[]
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("groovy");
// end::jsr223_init[]
// tag::jsr223_basic[]
Integer sum = (Integer) engine.eval("(1..10).sum()");
assertEquals(new Integer(55), sum);
// end::jsr223_basic[]
// tag::jsr223_variables[]
engine.put("first", "HELLO");
engine.put("second", "world");
String result = (String) engine.eval("first.toLowerCase() + ' ' + second.toUpperCase()");
assertEquals("hello WORLD", result);
// end::jsr223_variables[]
}
use of javax.script.ScriptEngineManager in project es6draft by anba.
the class InvocableTest method setUp.
@Before
public void setUp() {
manager = new ScriptEngineManager();
engine = manager.getEngineByName("es6draft");
assertThat(engine, notNullValue());
assertThat(engine, instanceOf(Invocable.class));
invocable = (Invocable) engine;
}
use of javax.script.ScriptEngineManager in project es6draft by anba.
the class TypeConversionTest method setUp.
@Before
public void setUp() {
manager = new ScriptEngineManager();
engine = manager.getEngineByName("es6draft");
assertThat(engine, notNullValue());
}
Aggregations