use of com.oracle.truffle.api.test.polyglot.ProxyLanguage in project graal by oracle.
the class LegacyTruffleExceptionTest method testPolyglotStackTrace.
@Test
public void testPolyglotStackTrace() {
setupEnv(Context.create(), new ProxyLanguage() {
@Override
protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Exception {
ThrowNode throwNode = new ThrowNode((n) -> {
return new LegacyCatchableException("Test exception", n);
});
return new TestRootNode(languageInstance, "test", null, throwNode).getCallTarget();
}
});
assertFails(() -> context.eval(ProxyLanguage.ID, "Test"), PolyglotException.class, (pe) -> {
TruffleExceptionTest.verifyStackTrace(pe, "<proxyLanguage> test", "(org.graalvm.sdk/)?org.graalvm.polyglot.Context.eval");
});
}
use of com.oracle.truffle.api.test.polyglot.ProxyLanguage in project graal by oracle.
the class ManualSamplingTest method setup.
@Before
public void setup() {
enterContext = false;
enteredSample = new Semaphore(0);
leaveSample = new Semaphore(0);
setupEnv(Context.newBuilder().build(), new ProxyLanguage() {
@Override
protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) {
return true;
}
});
context.eval(InstrumentationTestLanguage.ID, "DEFINE(sample, ROOT)");
instrumentEnv.getInstrumenter().attachExecutionEventListener(SourceSectionFilter.newBuilder().rootNameIs((s) -> s.equals("sample")).tagIs(RootTag.class).build(), new ExecutionEventListener() {
public void onEnter(EventContext c, VirtualFrame frame) {
enteredSample.release(1);
TruffleSafepoint.setBlockedThreadInterruptible(c.getInstrumentedNode(), Semaphore::acquire, leaveSample);
}
public void onReturnValue(EventContext c, VirtualFrame frame, Object result) {
}
public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable exception) {
}
});
sampler = CPUSampler.find(context.getEngine());
sampler.setFilter(DEFAULT_FILTER);
}
use of com.oracle.truffle.api.test.polyglot.ProxyLanguage in project graal by oracle.
the class ProxyLanguageEnvTest method before.
@Before
public void before() {
context = Context.newBuilder().allowAllAccess(true).build();
ProxyLanguage.setDelegate(new ProxyLanguage() {
@Override
protected LanguageContext createContext(Env contextEnv) {
env = contextEnv;
return super.createContext(contextEnv);
}
});
context.initialize(ProxyLanguage.ID);
context.enter();
assertNotNull(env);
}
use of com.oracle.truffle.api.test.polyglot.ProxyLanguage in project graal by oracle.
the class NodeAssertionsTest method testView.
@Test
@SuppressWarnings("hiding")
public void testView() {
try (Context context = Context.create()) {
ProxyLanguage language = new ProxyLanguage();
ProxyLanguage.setDelegate(language);
context.initialize(ProxyLanguage.ID);
context.enter();
Frame frame = Truffle.getRuntime().createMaterializedFrame(new Object[] {});
TestAssertsNode n = new TestAssertsNode(ProxyLanguage.get(null), frame.getFrameDescriptor());
NodeLibrary l = createLibrary(NodeLibrary.class, n);
n.getView = (f, x) -> x;
assertFails(() -> l.getView(n, null, true), AssertionError.class);
assertFails(() -> l.getView(n, null, new Object()), AssertionError.class);
assertFails(() -> l.getView(n, frame, true), AssertionError.class);
assertFails(() -> l.getView(n, frame, new Object()), AssertionError.class);
NodeDefaultsTest.ProxyLanguageValue pv = new NodeDefaultsTest.ProxyLanguageValue();
assertSame(pv, l.getView(n, frame, pv));
assertFails(() -> l.getView(n, null, pv), AssertionError.class);
assertFails(() -> l.getView(new TestAssertsNode(ProxyLanguage.get(null), null), frame, pv), AssertionError.class);
assertFails(() -> l.getView(new TestAssertsNode(null, frame.getFrameDescriptor()), frame, pv), AssertionError.class);
}
}
Aggregations