use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class TestRealms method newRealm.
public final Realm newRealm(Console console, TEST test) throws MalformedNameException, ResolutionException, IOException {
RuntimeContext context = createContext(console, test);
World world = new World(context);
Realm realm = Realm.InitializeHostDefinedRealm(world);
// Evaluate additional initialization scripts and modules
TestModuleLoader<?> moduleLoader = (TestModuleLoader<?>) world.getModuleLoader();
for (ModuleRecord module : modules.allModules) {
moduleLoader.defineFromTemplate(module, realm);
}
for (ModuleRecord module : modules.mainModules) {
ModuleRecord testModule = moduleLoader.get(module.getSourceCodeId(), realm);
testModule.instantiate();
testModule.evaluate();
}
for (Script script : scripts) {
script.evaluate(realm);
}
return realm;
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class Test262TestRealm method executeStrict.
/**
* Executes the supplied test object.
*
* @param test
* the test-info object
* @throws ParserException
* if the module source contains any syntax errors
* @throws CompilationException
* if the parsed module source cannot be compiled
*/
void executeStrict(Test262Info test) throws ParserException, CompilationException {
// Return early if no source code is available.
if (sourceCode == null) {
return;
}
assert !test.isAsync() || async != null;
assert !(test.isModule() || test.isRaw());
Realm realm = get();
// Parse the test-script
Source source = new Source(test.toFile(), test.getScript().toString(), 1);
ScriptLoader scriptLoader = realm.getScriptLoader();
EnumSet<Parser.Option> parserOptions = EnumSet.copyOf(realm.getRuntimeContext().getParserOptions());
parserOptions.add(Parser.Option.Strict);
Parser parser = new Parser(realm.getRuntimeContext(), source, parserOptions);
com.github.anba.es6draft.ast.Script parsedScript = parser.parseScript(sourceCode);
// Evaluate the test-script
Script script = scriptLoader.load(parsedScript);
script.evaluate(realm);
// Wait for pending jobs to finish
waitForPendingJobs(realm, test);
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class WebkitTest method runTest.
@Test
public void runTest() throws Throwable {
Realm realm = this.realm.get();
// Evaluate actual test-script
// - load and execute pre and post before resp. after test-script
ScriptLoading.include(realm, test.getBaseDir().resolve("resources/standalone-pre.js"));
ScriptLoading.eval(realm, test.getScript(), test.toFile());
ScriptLoading.include(realm, test.getBaseDir().resolve("resources/standalone-post.js"));
// Wait for pending jobs to finish
realm.getWorld().runEventLoop();
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class TestRealm method execute.
/**
* Executes the supplied test object.
*
* @param test
* the test-info object
* @throws IOException
* if there was any I/O error
* @throws MalformedNameException
* if any imported module request cannot be normalized
* @throws ResolutionException
* if any export binding cannot be resolved
* @throws ParserException
* if the module source contains any syntax errors
* @throws CompilationException
* if the parsed module source cannot be compiled
*/
public void execute(TEST test) throws ParserException, CompilationException, IOException, MalformedNameException, ResolutionException {
Realm realm = get();
// Evaluate actual test-script
if (test.isModule()) {
ScriptLoading.evalModule(realm, test.toModuleName());
} else {
ScriptLoading.eval(realm, test.getScript(), test.toFile());
}
// Wait for pending jobs to finish
realm.getWorld().runEventLoop();
}
use of com.github.anba.es6draft.runtime.Realm in project es6draft by anba.
the class TestRealm method execute.
/**
* Executes the supplied test object.
*
* @param test
* the test-info object
* @param jobSource
* the job source
* @throws IOException
* if there was any I/O error
* @throws MalformedNameException
* if any imported module request cannot be normalized
* @throws ResolutionException
* if any export binding cannot be resolved
* @throws ParserException
* if the module source contains any syntax errors
* @throws CompilationException
* if the parsed module source cannot be compiled
* @throws InterruptedException
* if interrupted while waiting
*/
public void execute(TEST test, JobSource jobSource) throws ParserException, CompilationException, IOException, MalformedNameException, ResolutionException, InterruptedException {
Realm realm = get();
// Evaluate actual test-script
if (test.isModule()) {
ScriptLoading.evalModule(realm, test.toModuleName());
} else {
ScriptLoading.eval(realm, test.getScript(), test.toFile());
}
// Wait for pending jobs to finish
realm.getWorld().runEventLoop(jobSource);
}
Aggregations