forked from tc39/test262
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add templates and cases for new
import defer
eval trigger tests
- Loading branch information
1 parent
27e9c16
commit 369a00a
Showing
22 changed files
with
485 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/import-defer/evaluation-triggers/defineOwnProperty.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc | ||
desc: _ [[DefineOwnProperty]] | ||
info: | | ||
[[DefineOwnProperty]] ( _P_, _Desc_ ) | ||
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryDefineOwnProperty(_O_, _Desc_). | ||
1. Let _current_ be ? _O_.[[GetOwnProperty]](_P_). | ||
1. NOTE: If _O_.[[Deferred]] is *true*, the step above will ensure that the module is evaluated. | ||
1. ... | ||
|
||
template: trigger-on-possible-export | ||
---*/ | ||
|
||
//- body | ||
try { | ||
Object.defineProperty(ns, key, { value: "hi" }); | ||
} catch (_) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-delete-p | ||
desc: _ [[Delete]] | ||
info: | | ||
[[Delete]] ( _P_ ) | ||
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryDelete(_O_, _P_). | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger-on-possible-export | ||
---*/ | ||
|
||
//- body | ||
try { | ||
delete ns[key]; | ||
} catch (_) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-get-p-receiver | ||
desc: _ [[Get]] | ||
info: | | ||
[[Get]] ( _P_, _Receiver_ ) | ||
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_). | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger-on-possible-export | ||
---*/ | ||
|
||
//- body | ||
ns[key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-getownproperty-p | ||
desc: _ [[GetOwnProperty]] | ||
info: | | ||
[[GetOwnProperty]] ( _P_ ) | ||
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGetOwnProperty(_O_, _P_). | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger-on-possible-export | ||
---*/ | ||
|
||
//- body | ||
Object.getOwnPropertyDescriptor(ns, key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-getprototypeof | ||
desc: _ [[GetPrototypeOf]] | ||
info: | | ||
[[GetPrototypeOf]] ( ) | ||
1. Return **null**. | ||
|
||
template: ignore | ||
---*/ | ||
|
||
//- body | ||
Object.getPrototypeOf(ns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-hasproperty-p | ||
desc: _ [[HasProperty]] | ||
info: | | ||
[[HasProperty]] ( _P_, _Receiver_ ) | ||
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_). | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger-on-possible-export | ||
---*/ | ||
|
||
//- body | ||
key in ns; |
21 changes: 21 additions & 0 deletions
21
src/import-defer/evaluation-triggers/ignore/ignore.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/import/import-defer/evaluation-triggers/ignore- | ||
name: does not trigger execution | ||
esid: sec-module-namespace-exotic-objects | ||
|
||
flags: [module] | ||
features: [import-defer] | ||
---*/ | ||
|
||
import "./setup_FIXTURE.js"; | ||
|
||
import defer * as ns from "./dep_FIXTURE.js"; | ||
|
||
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation"); | ||
|
||
/*{ body }*/ | ||
|
||
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-isextensible | ||
desc: _ [[IsExtensible]] | ||
info: | | ||
[[IsExtensible]] ( ) | ||
1. Return **false**. | ||
|
||
template: ignore | ||
---*/ | ||
|
||
//- body | ||
Object.isExtensible(ns); |
16 changes: 16 additions & 0 deletions
16
src/import-defer/evaluation-triggers/ownPropertyKey-names.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-ownpropertykeys | ||
desc: _ [[OwnPropertyKeys]] | ||
info: | | ||
[[OwnPropertyKeys]] ( ) | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger | ||
---*/ | ||
|
||
//- body | ||
Object.getOwnPropertyNames(ns); |
16 changes: 16 additions & 0 deletions
16
src/import-defer/evaluation-triggers/ownPropertyKeys-symbols.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-ownpropertykeys | ||
desc: _ [[OwnPropertyKeys]] | ||
info: | | ||
[[OwnPropertyKeys]] ( ) | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger | ||
---*/ | ||
|
||
//- body | ||
Object.getOwnPropertySymbols(ns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-ownpropertykeys | ||
desc: _ [[OwnPropertyKeys]] | ||
info: | | ||
[[OwnPropertyKeys]] ( ) | ||
1. Let _exports_ be ? GetModuleExportsList(_O_). | ||
1. ... | ||
|
||
template: trigger | ||
---*/ | ||
|
||
//- body | ||
Reflect.ownKeys(ns); |
15 changes: 15 additions & 0 deletions
15
src/import-defer/evaluation-triggers/preventExtensions.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-preventextensions | ||
desc: _ [[IsExtensible]] | ||
info: | | ||
[[IsExtensible]] ( ) | ||
1. Return **false**. | ||
|
||
template: ignore | ||
---*/ | ||
|
||
//- body | ||
Object.preventExtensions(ns); |
17 changes: 17 additions & 0 deletions
17
src/import-defer/evaluation-triggers/set-string-exported.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-set-p-v-receiver | ||
desc: _ [[Set]] of a string which is an export name | ||
info: | | ||
[[Set]] ( _P_, _V_, _Receiver_ ) | ||
1. Return **false**. | ||
|
||
template: ignore | ||
---*/ | ||
|
||
//- body | ||
try { | ||
ns.exported = "hi"; | ||
} catch (_) {} |
17 changes: 17 additions & 0 deletions
17
src/import-defer/evaluation-triggers/set-string-not-exported.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-set-p-v-receiver | ||
desc: _ [[Set]] of a string which is not an export name | ||
info: | | ||
[[Set]] ( _P_, _V_, _Receiver_ ) | ||
1. Return **false**. | ||
|
||
template: ignore | ||
---*/ | ||
|
||
//- body | ||
try { | ||
ns.notExported = "hi"; | ||
} catch (_) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-module-namespace-exotic-objects-setprototypeof | ||
desc: _ [[PreventExtensions]] | ||
info: | | ||
[[PreventExtensions]] ( ) | ||
1. Return **true**. | ||
|
||
template: ignore | ||
---*/ | ||
|
||
//- body | ||
Reflect.setPrototypeOf(ns, null); | ||
Reflect.setPrototypeOf(ns, {}); |
35 changes: 35 additions & 0 deletions
35
src/import-defer/evaluation-triggers/trigger-on-possible-export/string-exported.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/import/import-defer/evaluation-triggers/trigger-exported-string- | ||
name: of a string that is an exported name, triggers execution | ||
esid: sec-module-namespace-exotic-objects | ||
info: | | ||
IsSymbolLikeNamespaceKey ( _P_, _O_ ) | ||
1. If _P_ is a Symbol, return *true*. | ||
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*. | ||
1. Return *false*. | ||
|
||
GetModuleExportsList ( _O_ ) | ||
1. If _O_.[[Deferred]] is *true*, then | ||
1. Let _m_ be _O_.[[Module]]. | ||
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception. | ||
1. Perform ? EvaluateSync(_m_). | ||
1. Return _O_.[[Exports]]. | ||
|
||
flags: [module] | ||
features: [import-defer] | ||
---*/ | ||
|
||
import "./setup_FIXTURE.js"; | ||
|
||
import defer * as ns from "./dep_FIXTURE.js"; | ||
|
||
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation"); | ||
|
||
var key = "exported"; | ||
|
||
/*{ body }*/ | ||
|
||
assert(globalThis.evaluations.length > 0, "It triggers evaluation"); |
35 changes: 35 additions & 0 deletions
35
src/import-defer/evaluation-triggers/trigger-on-possible-export/string-not-exported.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/import/import-defer/evaluation-triggers/trigger-not-exported-string- | ||
name: of a string that is not an exported name, triggers execution | ||
esid: sec-module-namespace-exotic-objects | ||
info: | | ||
IsSymbolLikeNamespaceKey ( _P_, _O_ ) | ||
1. If _P_ is a Symbol, return *true*. | ||
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*. | ||
1. Return *false*. | ||
|
||
GetModuleExportsList ( _O_ ) | ||
1. If _O_.[[Deferred]] is *true*, then | ||
1. Let _m_ be _O_.[[Module]]. | ||
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception. | ||
1. Perform ? EvaluateSync(_m_). | ||
1. Return _O_.[[Exports]]. | ||
|
||
flags: [module] | ||
features: [import-defer] | ||
---*/ | ||
|
||
import "./setup_FIXTURE.js"; | ||
|
||
import defer * as ns from "./dep_FIXTURE.js"; | ||
|
||
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation"); | ||
|
||
var key = "notExported"; | ||
|
||
/*{ body }*/ | ||
|
||
assert(globalThis.evaluations.length > 0, "It triggers evaluation"); |
35 changes: 35 additions & 0 deletions
35
src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-other.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/import/import-defer/evaluation-triggers/ignore-symbol-other- | ||
name: of a symbol that is not a property of the namespace object, does not trigger execution | ||
esid: sec-module-namespace-exotic-objects | ||
info: | | ||
IsSymbolLikeNamespaceKey ( _P_, _O_ ) | ||
1. If _P_ is a Symbol, return *true*. | ||
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*. | ||
1. Return *false*. | ||
|
||
GetModuleExportsList ( _O_ ) | ||
1. If _O_.[[Deferred]] is *true*, then | ||
1. Let _m_ be _O_.[[Module]]. | ||
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception. | ||
1. Perform ? EvaluateSync(_m_). | ||
1. Return _O_.[[Exports]]. | ||
|
||
flags: [module] | ||
features: [import-defer] | ||
---*/ | ||
|
||
import "./setup_FIXTURE.js"; | ||
|
||
import defer * as ns from "./dep_FIXTURE.js"; | ||
|
||
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation"); | ||
|
||
var key = Symbol(); | ||
|
||
/*{ body }*/ | ||
|
||
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation"); |
Oops, something went wrong.