diff --git a/test/language/import/import-defer/deferred-namespace-object/exotic-object-behavior.js b/test/language/import/import-defer/deferred-namespace-object/exotic-object-behavior.js index 4274b6e170..2b2b041ae9 100644 --- a/test/language/import/import-defer/deferred-namespace-object/exotic-object-behavior.js +++ b/test/language/import/import-defer/deferred-namespace-object/exotic-object-behavior.js @@ -35,7 +35,7 @@ assert.sameValue(Reflect.setPrototypeOf(ns, {}), false, "Deferred namespaces' pr assert.sameValue(Reflect.setPrototypeOf(ns, null), true, "Deferred namespaces' prototype can be 'set' to null"); assert.throws(TypeError, () => Reflect.apply(ns, null, []), "Deferred namespaces are not callable"); -assert.throws(TypeError, () => Reflect.construct(ns, null, []), "Deferred namespaces are not constructable"); +assert.throws(TypeError, () => Reflect.construct(ns, [], ns), "Deferred namespaces are not constructable"); assert.compareArray( Reflect.ownKeys(ns), diff --git a/test/language/import/import-defer/errors/get-self-while-evaluating-async/main.js b/test/language/import/import-defer/errors/get-self-while-evaluating-async/main.js index d51ec49f35..069d07699e 100644 --- a/test/language/import/import-defer/errors/get-self-while-evaluating-async/main.js +++ b/test/language/import/import-defer/errors/get-self-while-evaluating-async/main.js @@ -29,6 +29,17 @@ flags: [module, async] features: [import-defer, top-level-await] ---*/ +/* +`./dep_FIXTURE.js` is _not_ deferred, because it contains top-level await. So what is happening in this test is that: +- the deferred module is not actually deferred, so `dep_FIXTURE.js` starts executing and goes in its `evaluating` state +- it has access to a deferred namespace of itself +- once it reaches the `await`, the state changes to `evaluating-async` +- the test tries then to access a property from the deferred namespace while it's `evaluating-async` (which is what this test it testing). It should throw. +- `dep_FIXTURE.js` is done, and becomes `evaluated` +- `main.js` starts evaluating, and the error is already there +- `ns.foo` now works, because `ns` is `evaluated` and not `evaluating-async` +*/ + import defer * as ns from "./dep_FIXTURE.js"; assert(globalThis["error on ns.foo"] instanceof TypeError, "ns.foo while evaluating throws a TypeError"); diff --git a/test/language/import/import-defer/errors/module-throws/defer-import-after-evaluation.js b/test/language/import/import-defer/errors/module-throws/defer-import-after-evaluation.js index 92b6bdf740..cb32449e1c 100644 --- a/test/language/import/import-defer/errors/module-throws/defer-import-after-evaluation.js +++ b/test/language/import/import-defer/errors/module-throws/defer-import-after-evaluation.js @@ -26,13 +26,13 @@ info: | flags: [module, async] features: [import-defer] -includes: [asyncHelpers.js, deepEqual.js] +includes: [asyncHelpers.js] ---*/ asyncTest(async () => { let err1; await import("./throws_FIXTURE.js").catch((e) => { err1 = e }); - assert.deepEqual(err1, { someError: "the error from throws_FIXTURE" }); + assert.sameValue(err1.someError, "the error from throws_FIXTURE"); const { ns } = await import("./import-defer-throws_FIXTURE.js"); diff --git a/test/language/import/import-defer/errors/module-throws/third-party-evaluation-after-defer-import.js b/test/language/import/import-defer/errors/module-throws/third-party-evaluation-after-defer-import.js index 42b86f7b44..ad37535b4a 100644 --- a/test/language/import/import-defer/errors/module-throws/third-party-evaluation-after-defer-import.js +++ b/test/language/import/import-defer/errors/module-throws/third-party-evaluation-after-defer-import.js @@ -26,7 +26,7 @@ info: | flags: [module, async] features: [import-defer] -includes: [asyncHelpers.js, deepEqual.js] +includes: [asyncHelpers.js] ---*/ import defer * as ns from "./throws_FIXTURE.js"; @@ -34,7 +34,7 @@ import defer * as ns from "./throws_FIXTURE.js"; asyncTest(async () => { let err1; await import("./throws_FIXTURE.js").catch((e) => { err1 = e }); - assert.deepEqual(err1, { someError: "the error from throws_FIXTURE" }); + assert.sameValue(err1.someError, "the error from throws_FIXTURE"); let err2; try { ns.foo } catch (e) { err2 = e }; diff --git a/test/language/import/import-defer/errors/module-throws/trigger-evaluation.js b/test/language/import/import-defer/errors/module-throws/trigger-evaluation.js index 337b49c96c..e18d4dec0f 100644 --- a/test/language/import/import-defer/errors/module-throws/trigger-evaluation.js +++ b/test/language/import/import-defer/errors/module-throws/trigger-evaluation.js @@ -26,7 +26,6 @@ info: | flags: [module] features: [import-defer] -includes: [deepEqual.js] ---*/ import defer * as ns from "./throws_FIXTURE.js"; diff --git a/test/language/import/import-defer/errors/resolution-error/import-defer-of-syntax-error-fails.js b/test/language/import/import-defer/errors/resolution-error/import-defer-of-missing-module-fails.js similarity index 100% rename from test/language/import/import-defer/errors/resolution-error/import-defer-of-syntax-error-fails.js rename to test/language/import/import-defer/errors/resolution-error/import-defer-of-missing-module-fails.js diff --git a/test/language/import/import-defer/syntax/valid-default-binding-named-defer.js b/test/language/import/import-defer/syntax/valid-default-binding-named-defer.js index 16743bac5b..a69b000742 100644 --- a/test/language/import/import-defer/syntax/valid-default-binding-named-defer.js +++ b/test/language/import/import-defer/syntax/valid-default-binding-named-defer.js @@ -26,3 +26,5 @@ features: [import-defer] ---*/ import defer from "./dep_FIXTURE.js"; + +asserts.sameValue(defer, 1, "`defer` is the default export binding");