fix(evaluate): be more careful with evaluation
Fixes fixes
Delete `globalObject.test262` to increase isolation.  Still not perfect.
Refs
MODIFY
package-lock.json
package-lock.json
}
},
"@agoric/transform-module": {
- "version": "0.2.0",
- "resolved": "https://registry.npmjs.org/@agoric/transform-module/-/transform-module-0.2.0.tgz",
- "integrity": "sha512-8OsnjDWkQgh+JIM9qFxDQLbNop0uEEVd8+qZn5V7feghJqeGCglNWInIo5fzSDTl8WoeVZmY6+Ao9oae0cDrTA==",
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/@agoric/transform-module/-/transform-module-0.2.2.tgz",
+ "integrity": "sha512-bCV61s/9rmSaLxW0TNoppIcc1OifOrYy/6k9Uyd9Ialr9i8SDpAvk1/wB0TyUYNvUMqE7OY1jNOTQteKaH8CdA==",
"dev": true,
"requires": {
"@agoric/evaluate": "^2.1.3",
"dev": true
},
"@types/node": {
- "version": "12.12.11",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz",
- "integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==",
+ "version": "12.12.12",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.12.tgz",
+ "integrity": "sha512-MGuvYJrPU0HUwqF7LqvIj50RZUX23Z+m583KBygKYUZLlZ88n6w28XRNJRJgsHukLEnLz6w6SvxZoLgbr5wLqQ==",
"dev": true
},
"@types/resolve": {

MODIFY
package.json
package.json
},
"devDependencies": {
"@agoric/evaluate": "^2.1.3",
- "@agoric/transform-module": "^0.2.0",
+ "@agoric/transform-module": "^0.2.2",
"@babel/core": "^7.7.2",
"eslint": "^6.1.0",
"eslint-config-airbnb-base": "^14.0.0",

MODIFY
src/moduleInstance.js
src/moduleInstance.js
@@ -205,7 +205,7 @@ export function makeModuleInstance(
// The updateRecord must conform to linkageRecord.imports
// updateRecord = Map<specifier, importUpdaters>
// importUpdaters = Map<importName, [update(newValue)*]>
- async function imports(updateRecord) {
+ function imports(updateRecord) {
// By the time imports is called, the importNS should already be
// initialized with module instances that satisfy
// linkageRecord.imports.
@@ -218,9 +218,7 @@ export function makeModuleInstance(
for (const [specifier, importUpdaters] of updateRecord.entries()) {
const moduleId = linkageRecord.moduleIds[specifier];
const instance = importNS.get(moduleId);
- const p = instance
- .initialize() // bottom up cycle tolerant
- .then(() => {
+ instance.initialize(); // bottom up cycle tolerant
const { notifiers: modNotifiers } = instance;
for (const [importName, updaters] of importUpdaters.entries()) {
const notify = modNotifiers[importName];
@@ -244,10 +242,7 @@ export function makeModuleInstance(
}
}
}
- });
- ps.push(p);
}
- await Promise.all(ps);
for (const [importName, notify] of Object.entries(candidateAll)) {
if (!notifiers[importName] && notify !== false) {
@@ -285,16 +280,27 @@ export function makeModuleInstance(
});
const { functorSource } = linkageRecord;
+ // console.log(functorSource);
let optFunctor = evaluator(functorSource, endowments);
- async function initialize() {
+ let didThrow = false;
+ let thrownError;
+ function initialize() {
if (optFunctor) {
// uninitialized
const functor = optFunctor;
optFunctor = null;
// initializing - call with `this` of `undefined`.
- await functor(harden({ imports, onceVar, liveVar }));
+ try {
+ functor(harden({ imports, onceVar, liveVar }));
+ } catch (e) {
+ didThrow = true;
+ thrownError = e;
+ }
// initialized
}
+ if (didThrow) {
+ throw thrownError;
+ }
}
return harden({

MODIFY
test/test-test262.js
test/test-test262.js
@@ -97,19 +97,6 @@ function hasExcludedInfo(testInfo) {
// some tests fail because they rely on a side effect which is failing
// resolving an issue might uncover another issue
- // 'Statement cannot contain an `import` declaration', // https://github.com/Agoric/transform-module/issues/5
- // 'Expression cannot contain an `import` declaration', // https://github.com/Agoric/transform-module/issues/5
- // 'Statement cannot contain an `export` declaration', // https://github.com/Agoric/transform-module/issues/5
- // 'Expression cannot contain an `export` declaration', // https://github.com/Agoric/transform-module/issues/5
-
- // 'Default AssignmentExpression (which can be recognized as an "anonymous"', // https://github.com/Agoric/make-importer/issues/10
-
- // 'An exported default "anonymous"', // https://github.com/Agoric/make-importer/issues/12
- // 'Default "anonymous', // https://github.com/Agoric/make-importer/issues/12
- // 'An exported default "named"', // https://github.com/Agoric/make-importer/issues/12
-
- // 'The [[OwnPropertyKeys]] internal method reflects the sorted order', // https://github.com/Agoric/make-importer/issues/24
-
'Behavior of the [[HasProperty]] internal method', // https://github.com/Agoric/make-importer/issues/?
'Behavior of the [[GetOwnProperty]] internal method', // https://github.com/Agoric/make-importer/issues/?
'Behavior of the [[Get]] internal method', // https://github.com/Agoric/make-importer/issues/?
@@ -122,27 +109,18 @@ function hasExcludedInfo(testInfo) {
'Modules can be visited more than once', // https://github.com/Agoric/make-importer/issues/27
- // 'Ambiguous exports are not reflected', // https://github.com/Agoric/make-importer/issues/28
-
'`Symbol.toStringTag` property descriptor', // https://github.com/Agoric/make-importer/issues/29
- // 'Hashbang comments', // https://github.com/Agoric/make-importer/issues/34
-
- // 'The class-name is present', // https://github.com/Agoric/make-importer/issues/35
-
- 'Module is evaluated exactly once', // https://github.com/Agoric/make-importer/issues/36
- 'Requested modules are evaluated exactly once', // https://github.com/Agoric/make-importer/issues/36
+ // 'Module is evaluated exactly once', // https://github.com/Agoric/make-importer/issues/36
+ // 'Requested modules are evaluated exactly once', // https://github.com/Agoric/make-importer/issues/36
'The [[SetPrototypeOf]] internal method returns `false`', // https://github.com/Agoric/make-importer/issues/39
- // 'References observe the initialization of lexical bindings', // https://github.com/Agoric/make-importer/issues/40
- // 'References observe the mutation of initialized bindings', // https://github.com/Agoric/make-importer/issues/40
-
// 'Requested modules are evaluated prior to the requesting module in source code order', // https://github.com/Agoric/make-importer/issues/43
'Modifications to default binding that occur after dependency has been evaluated', // https://github.com/Agoric/make-importer/issues/12
- 'Abrupt completion during module evaluation', // https://github.com/Agoric/make-importer/issues/44
+ // 'Abrupt completion during module evaluation', // https://github.com/Agoric/make-importer/issues/44
];
return excludePaths.some(exclude => description.startsWith(exclude));
}
@@ -153,6 +131,7 @@ function hasExcludedInfo(testInfo) {
* Create a new (and related) pair of evaluator and importer.
*/
function makeEvaluatorAndImporter(rootUrl) {
+ // This cleans up the global state between tests.
const transforms = [];
const { evaluateProgram } = makeEvaluators({ transforms });
const importer = makeImporter({
@@ -197,6 +176,7 @@ function injectTest262Harness(globalObject, t) {
$ERROR,
$DONOTEVALUATE,
});
+ delete globalObject.test262;
// ===
// from test262/harness/assert.js

fix(evaluate): be more careful with evaluation

Fixes #43, fixes #44

Delete `globalObject.test262` to increase isolation.  Still not perfect.
Refs #36