use of org.graalvm.polyglot.Context in project graal by oracle.
the class LanguageSPIOrderTest method testActivateDuringFinalize.
@Test
public void testActivateDuringFinalize() {
Context context = Context.create();
context.initialize(ACTIVATE_DURING_FINALIZE);
assertNotNull(getOrder(ACTIVATE_DURING_FINALIZE));
assertEquals(0, getOrder(ACTIVATE_DURING_FINALIZE).createContext);
assertEquals(1, getOrder(ACTIVATE_DURING_FINALIZE).initializeThread);
assertEquals(2, getOrder(ACTIVATE_DURING_FINALIZE).initializeContext);
/*
* context uses PUBLIC which uses INTERNAL in the finalizeContext methods
*/
context.close();
assertEquals(3, getOrder(ACTIVATE_DURING_FINALIZE).finalizeContext);
assertEquals(4, getOrder(PUBLIC).createContext);
assertEquals(5, getOrder(INTERNAL).createContext);
assertEquals(6, getOrder(INTERNAL).initializeThread);
assertEquals(7, getOrder(INTERNAL).initializeContext);
assertEquals(8, getOrder(PUBLIC).initializeThread);
assertEquals(9, getOrder(PUBLIC).initializeContext);
assertEquals(10, getOrder(PUBLIC).finalizeContext);
assertEquals(11, getOrder(INTERNAL).finalizeContext);
assertEquals(12, getOrder(ACTIVATE_DURING_FINALIZE).disposeThread);
assertEquals(13, getOrder(ACTIVATE_DURING_FINALIZE).disposeContext);
assertEquals(14, getOrder(PUBLIC).disposeThread);
assertEquals(15, getOrder(PUBLIC).disposeContext);
assertEquals(16, getOrder(INTERNAL).disposeThread);
assertEquals(17, getOrder(INTERNAL).disposeContext);
}
use of org.graalvm.polyglot.Context in project graal by oracle.
the class LanguageSPIOrderTest method testOrderSimple.
@Test
public void testOrderSimple() {
Context context = Context.create();
context.initialize(PUBLIC);
assertNotNull(getOrder(PUBLIC));
assertNotNull(getOrder(INTERNAL));
assertEquals(0, getOrder(PUBLIC).createContext);
assertEquals(1, getOrder(INTERNAL).createContext);
assertEquals(2, getOrder(INTERNAL).initializeThread);
assertEquals(3, getOrder(INTERNAL).initializeContext);
assertEquals(4, getOrder(PUBLIC).initializeThread);
assertEquals(5, getOrder(PUBLIC).initializeContext);
context.close();
assertEquals(6, getOrder(PUBLIC).finalizeContext);
assertEquals(7, getOrder(INTERNAL).finalizeContext);
assertEquals(8, getOrder(PUBLIC).disposeThread);
assertEquals(9, getOrder(PUBLIC).disposeContext);
assertEquals(10, getOrder(INTERNAL).disposeThread);
assertEquals(11, getOrder(INTERNAL).disposeContext);
}
use of org.graalvm.polyglot.Context in project graal by oracle.
the class LanguageSPIOrderTest method testOrderDependent.
@Test
public void testOrderDependent() {
Context context = Context.create();
context.initialize(TRANSITIVE);
assertNotNull(getOrder(TRANSITIVE));
assertNotNull(getOrder(DEPENDENT));
assertNotNull(getOrder(PUBLIC));
assertNotNull(getOrder(INTERNAL));
assertEquals(0, getOrder(TRANSITIVE).createContext);
assertEquals(1, getOrder(TRANSITIVE).initializeThread);
assertEquals(2, getOrder(TRANSITIVE).initializeContext);
assertEquals(3, getOrder(DEPENDENT).createContext);
assertEquals(4, getOrder(DEPENDENT).initializeThread);
assertEquals(5, getOrder(DEPENDENT).initializeContext);
assertEquals(6, getOrder(PUBLIC).createContext);
assertEquals(7, getOrder(INTERNAL).createContext);
assertEquals(8, getOrder(INTERNAL).initializeThread);
assertEquals(9, getOrder(INTERNAL).initializeContext);
assertEquals(10, getOrder(PUBLIC).initializeThread);
assertEquals(11, getOrder(PUBLIC).initializeContext);
context.close();
assertEquals(12, getOrder(TRANSITIVE).finalizeContext);
assertEquals(13, getOrder(DEPENDENT).finalizeContext);
assertEquals(14, getOrder(PUBLIC).finalizeContext);
assertEquals(15, getOrder(INTERNAL).finalizeContext);
assertEquals(16, getOrder(TRANSITIVE).disposeThread);
assertEquals(17, getOrder(TRANSITIVE).disposeContext);
assertEquals(18, getOrder(DEPENDENT).disposeThread);
assertEquals(19, getOrder(DEPENDENT).disposeContext);
assertEquals(20, getOrder(PUBLIC).disposeThread);
assertEquals(21, getOrder(PUBLIC).disposeContext);
assertEquals(22, getOrder(INTERNAL).disposeThread);
assertEquals(23, getOrder(INTERNAL).disposeContext);
}
use of org.graalvm.polyglot.Context in project graal by oracle.
the class LanguageSPIOrderTest method testActivateDuringDispose.
@Test
public void testActivateDuringDispose() {
Context context = Context.create();
context.initialize(ACTIVATE_DURING_DISPOSE);
assertNotNull(getOrder(ACTIVATE_DURING_DISPOSE));
assertEquals(0, getOrder(ACTIVATE_DURING_DISPOSE).createContext);
assertEquals(1, getOrder(ACTIVATE_DURING_DISPOSE).initializeThread);
assertEquals(2, getOrder(ACTIVATE_DURING_DISPOSE).initializeContext);
context.close();
assertEquals(3, getOrder(ACTIVATE_DURING_DISPOSE).finalizeContext);
assertEquals(4, getOrder(ACTIVATE_DURING_DISPOSE).disposeThread);
assertEquals(5, getOrder(ACTIVATE_DURING_DISPOSE).disposeContext);
}
use of org.graalvm.polyglot.Context in project graal by oracle.
the class LanguageSPITest method testIsHostAccessAllowed.
@Test
public void testIsHostAccessAllowed() {
Context context = Context.newBuilder().allowHostAccess(false).build();
assertTrue(!eval(context, env -> env.isHostLookupAllowed()).asBoolean());
context.close();
context = Context.newBuilder().allowHostAccess(true).build();
assertTrue(eval(context, env -> env.isHostLookupAllowed()).asBoolean());
context.close();
}
Aggregations