-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b628e4b
commit ed0bf1c
Showing
154 changed files
with
5,819 additions
and
0 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
src/dynamic-import/import-source-assignment-expr-not-optional.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 Chengzhong Wu. All rights reserved. | ||
// Copyright (C) 2018 Rick Waldron. All rights reserved. | ||
// Copyright (C) 2018 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: It's a SyntaxError if AssignmentExpression is omitted | ||
template: syntax/invalid | ||
info: | | ||
ImportCall[Yield, Await] : | ||
import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) | ||
|
||
---*/ | ||
//- import | ||
import.source() | ||
//- teardown | ||
/* The params region intentionally empty */ |
12 changes: 12 additions & 0 deletions
12
src/dynamic-import/import-source-empty-str-is-valid-assign-expr.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,12 @@ | ||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved. | ||
// Copyright (C) 2018 Rick Waldron. All rights reserved. | ||
// Copyright (C) 2018 the V8 project authors. All rights reserved. | ||
|
||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: Calling import.source('') | ||
template: syntax/valid | ||
---*/ | ||
|
||
//- import | ||
import.source('') |
17 changes: 17 additions & 0 deletions
17
src/dynamic-import/import-source-no-new-call-expression.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 Chengzhong Wu. All rights reserved. | ||
// Copyright (C) 2018 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: ImportCall is a CallExpression, it can't be preceded by the new keyword | ||
template: syntax/invalid | ||
info: | | ||
CallExpression: | ||
ImportCall | ||
|
||
ImportCall : | ||
import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) | ||
|
||
---*/ | ||
|
||
//- import | ||
new import.source('') |
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,11 @@ | ||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: Dynamic import.source() returns a thenable object. | ||
template: default | ||
---*/ | ||
|
||
//- import | ||
import.source('./dynamic-import-module_FIXTURE.js') | ||
//- body | ||
assert.sameValue(typeof imported, 'object'); |
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 Chengzhong Wu. All rights reserved. | ||
// Copyright (C) 2018 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: import() can be used in script code | ||
template: syntax/valid | ||
---*/ | ||
|
||
//- setup | ||
// This is still valid in script code, and should not be valid for module code | ||
// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames | ||
var smoosh; function smoosh() {} | ||
|
||
//- import | ||
import.source('./empty_FIXTURE.js') |
41 changes: 41 additions & 0 deletions
41
src/dynamic-import/import-source-specifier-tostring-abrupt-rejects.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,41 @@ | ||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved. | ||
// Copyright (C) 2018 Rick Waldron. All rights reserved. | ||
// Copyright (C) 2018 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: > | ||
Abrupt from ToString(specifier) rejects the promise | ||
esid: sec-moduleevaluation | ||
info: | | ||
Import Calls | ||
|
||
Runtime Semantics: Evaluation | ||
|
||
ImportCall : import . source ( AssignmentExpression ) | ||
1. Return ? EvaluateImportCall(AssignmentExpression, source). | ||
|
||
13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase ) | ||
1. Let referrer be GetActiveScriptOrModule(). | ||
2. If referrer is null, set referrer to the current Realm Record. | ||
3. Let specifierRef be ? Evaluation of specifierExpression. | ||
4. Let specifier be ? GetValue(specifierRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be Completion(ToString(specifier)). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }. | ||
9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability). | ||
10. Return promiseCapability.[[Promise]]. | ||
template: catch | ||
---*/ | ||
|
||
//- setup | ||
const obj = { | ||
toString() { | ||
throw 'custom error'; | ||
} | ||
}; | ||
|
||
//- import | ||
import.source(obj) | ||
//- body | ||
assert.sameValue(error, 'custom error'); |
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,45 @@ | ||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved. | ||
// Copyright (C) 2018 Rick Waldron. All rights reserved. | ||
// Copyright (C) 2018 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
desc: > | ||
ToString value of specifier | ||
esid: sec-moduleevaluation | ||
info: | | ||
Import Calls | ||
|
||
Runtime Semantics: Evaluation | ||
|
||
ImportCall : import . source ( AssignmentExpression ) | ||
1. Return ? EvaluateImportCall(AssignmentExpression, source). | ||
|
||
13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase ) | ||
1. Let referrer be GetActiveScriptOrModule(). | ||
2. If referrer is null, set referrer to the current Realm Record. | ||
3. Let specifierRef be ? Evaluation of specifierExpression. | ||
4. Let specifier be ? GetValue(specifierRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be Completion(ToString(specifier)). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }. | ||
9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability). | ||
10. Return promiseCapability.[[Promise]]. | ||
template: default | ||
---*/ | ||
|
||
//- setup | ||
// import('./module-code_FIXTURE.js') | ||
|
||
const obj = { | ||
toString() { | ||
return './module-code_FIXTURE.js'; | ||
} | ||
}; | ||
|
||
//- import | ||
import(obj) | ||
//- body | ||
assert.sameValue(imported.default, 42); | ||
assert.sameValue(imported.x, 'Test262'); | ||
assert.sameValue(imported.z, 42); |
59 changes: 59 additions & 0 deletions
59
...import/catch/nested-arrow-import-catch-import-source-specifier-tostring-abrupt-rejects.js
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,59 @@ | ||
// This file was procedurally generated from the following sources: | ||
// - src/dynamic-import/import-source-specifier-tostring-abrupt-rejects.case | ||
// - src/dynamic-import/catch/nested-arrow.template | ||
/*--- | ||
description: Abrupt from ToString(specifier) rejects the promise (nested arrow) | ||
esid: sec-import-call-runtime-semantics-evaluation | ||
features: [dynamic-import] | ||
flags: [generated, async] | ||
info: | | ||
ImportCall : | ||
import( AssignmentExpression ) | ||
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). | ||
2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). | ||
3. Let argRef be the result of evaluating AssignmentExpression. | ||
4. Let specifier be ? GetValue(argRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be ToString(specifier). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). | ||
9. Return promiseCapability.[[Promise]]. | ||
Import Calls | ||
Runtime Semantics: Evaluation | ||
ImportCall : import . source ( AssignmentExpression ) | ||
1. Return ? EvaluateImportCall(AssignmentExpression, source). | ||
13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase ) | ||
1. Let referrer be GetActiveScriptOrModule(). | ||
2. If referrer is null, set referrer to the current Realm Record. | ||
3. Let specifierRef be ? Evaluation of specifierExpression. | ||
4. Let specifier be ? GetValue(specifierRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be Completion(ToString(specifier)). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }. | ||
9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability). | ||
10. Return promiseCapability.[[Promise]]. | ||
---*/ | ||
const obj = { | ||
toString() { | ||
throw 'custom error'; | ||
} | ||
}; | ||
|
||
|
||
let f = () => { | ||
import.source(obj).catch(error => { | ||
|
||
assert.sameValue(error, 'custom error'); | ||
|
||
}).then($DONE, $DONE); | ||
}; | ||
|
||
f(); |
59 changes: 59 additions & 0 deletions
59
...atch/nested-async-arrow-function-await-import-source-specifier-tostring-abrupt-rejects.js
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,59 @@ | ||
// This file was procedurally generated from the following sources: | ||
// - src/dynamic-import/import-source-specifier-tostring-abrupt-rejects.case | ||
// - src/dynamic-import/catch/nested-async-arrow-fn-await.template | ||
/*--- | ||
description: Abrupt from ToString(specifier) rejects the promise (nested in async arrow function, awaited) | ||
esid: sec-import-call-runtime-semantics-evaluation | ||
features: [dynamic-import] | ||
flags: [generated, async] | ||
info: | | ||
ImportCall : | ||
import( AssignmentExpression ) | ||
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). | ||
2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). | ||
3. Let argRef be the result of evaluating AssignmentExpression. | ||
4. Let specifier be ? GetValue(argRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be ToString(specifier). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). | ||
9. Return promiseCapability.[[Promise]]. | ||
Import Calls | ||
Runtime Semantics: Evaluation | ||
ImportCall : import . source ( AssignmentExpression ) | ||
1. Return ? EvaluateImportCall(AssignmentExpression, source). | ||
13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase ) | ||
1. Let referrer be GetActiveScriptOrModule(). | ||
2. If referrer is null, set referrer to the current Realm Record. | ||
3. Let specifierRef be ? Evaluation of specifierExpression. | ||
4. Let specifier be ? GetValue(specifierRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be Completion(ToString(specifier)). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }. | ||
9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability). | ||
10. Return promiseCapability.[[Promise]]. | ||
---*/ | ||
const obj = { | ||
toString() { | ||
throw 'custom error'; | ||
} | ||
}; | ||
|
||
|
||
const f = async () => { | ||
await import.source(obj); | ||
} | ||
|
||
f().catch(error => { | ||
|
||
assert.sameValue(error, 'custom error'); | ||
|
||
}).then($DONE, $DONE); |
57 changes: 57 additions & 0 deletions
57
...sted-async-arrow-function-return-await-import-source-specifier-tostring-abrupt-rejects.js
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,57 @@ | ||
// This file was procedurally generated from the following sources: | ||
// - src/dynamic-import/import-source-specifier-tostring-abrupt-rejects.case | ||
// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template | ||
/*--- | ||
description: Abrupt from ToString(specifier) rejects the promise (nested in async arrow function, returned) | ||
esid: sec-import-call-runtime-semantics-evaluation | ||
features: [dynamic-import] | ||
flags: [generated, async] | ||
info: | | ||
ImportCall : | ||
import( AssignmentExpression ) | ||
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). | ||
2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). | ||
3. Let argRef be the result of evaluating AssignmentExpression. | ||
4. Let specifier be ? GetValue(argRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be ToString(specifier). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). | ||
9. Return promiseCapability.[[Promise]]. | ||
Import Calls | ||
Runtime Semantics: Evaluation | ||
ImportCall : import . source ( AssignmentExpression ) | ||
1. Return ? EvaluateImportCall(AssignmentExpression, source). | ||
13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase ) | ||
1. Let referrer be GetActiveScriptOrModule(). | ||
2. If referrer is null, set referrer to the current Realm Record. | ||
3. Let specifierRef be ? Evaluation of specifierExpression. | ||
4. Let specifier be ? GetValue(specifierRef). | ||
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). | ||
6. Let specifierString be Completion(ToString(specifier)). | ||
7. IfAbruptRejectPromise(specifierString, promiseCapability). | ||
8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }. | ||
9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability). | ||
10. Return promiseCapability.[[Promise]]. | ||
---*/ | ||
const obj = { | ||
toString() { | ||
throw 'custom error'; | ||
} | ||
}; | ||
|
||
|
||
const f = async () => await import.source(obj); | ||
|
||
f().catch(error => { | ||
|
||
assert.sameValue(error, 'custom error'); | ||
|
||
}).then($DONE, $DONE); |
Oops, something went wrong.