use of org.graalvm.polyglot.tck.InlineSnippet in project graal by oracle.
the class InlineExecutionTest method createScriptTests.
@Parameterized.Parameters(name = "{0}")
public static Collection<InlineTestRun> createScriptTests() {
context = new TestContext();
final Collection<InlineTestRun> res = new LinkedHashSet<>();
for (String lang : TestUtil.getRequiredLanguages(context)) {
for (InlineSnippet snippet : context.getInlineScripts(lang)) {
res.add(new InlineTestRun(new AbstractMap.SimpleImmutableEntry<>(lang, snippet.getScript()), snippet));
}
}
return res;
}
use of org.graalvm.polyglot.tck.InlineSnippet in project graal by oracle.
the class InlineExecutionTest method testInline.
@Test
public void testInline() throws Exception {
Assume.assumeThat(testRun, TEST_RESULT_MATCHER);
boolean success = false;
InlineSnippet inlineSnippet = testRun.getInlineSnippet();
TestResultVerifier verifier;
if (testRun.getInlineSnippet().getResultVerifier() != null) {
verifier = new TestResultVerifier();
} else {
verifier = null;
}
context.getContext().initialize(testRun.getID());
context.setInlineSnippet(testRun.getID(), inlineSnippet, verifier);
try {
try {
final Value result = testRun.getSnippet().getExecutableValue().execute(testRun.getActualParameters().toArray());
TestUtil.validateResult(testRun, result, null);
success = true;
} catch (PolyglotException pe) {
TestUtil.validateResult(testRun, null, pe);
success = true;
}
if (verifier != null && verifier.exception != null) {
success = false;
throw verifier.exception;
}
} finally {
context.setInlineSnippet(null, null, null);
TEST_RESULT_MATCHER.accept(new AbstractMap.SimpleImmutableEntry<>(testRun, success));
}
}
Aggregations