Skip to content

Commit c18c1dd

Browse files
committed
Remove source phase resolution time negative error types
1 parent 8296db8 commit c18c1dd

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

test/language/module-code/source-phase-import/import-source-binding-name-2.js test/language/module-code/source-phase-import/import-source-binding-name-2_FIXTURE.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
/*---
44
description: >
55
ImportBinding in ImportDeclaration may be 'source' and 'from'
6+
This test is verified with `import-source.js` in the same directory that
7+
this file does not raise SyntaxError. Note that a SyntaxError could also
8+
be raised when the imported module does not have a source phase
9+
representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
10+
611
esid: sec-modules
712
info: |
813
ImportDeclaration:
914
import source ImportedBinding FromClause ;
1015
1116
negative:
1217
phase: resolution
13-
type: SyntaxError
18+
type: Error
1419
features: [source-phase-imports]
1520
flags: [module]
1621
---*/

test/language/module-code/source-phase-import/import-source-binding-name.js test/language/module-code/source-phase-import/import-source-binding-name_FIXTURE.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
/*---
44
description: >
55
ImportBinding in ImportDeclaration may be 'source' and 'from'
6+
This test is verified with `import-source.js` in the same directory that
7+
this file does not raise SyntaxError. Note that a SyntaxError could also
8+
be raised when the imported module does not have a source phase
9+
representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
10+
611
esid: sec-modules
712
info: |
813
ImportDeclaration:
914
import source ImportedBinding FromClause ;
1015
1116
negative:
1217
phase: resolution
13-
type: SyntaxError
18+
type: Error
1419
features: [source-phase-imports]
1520
flags: [module]
1621
---*/

test/language/module-code/source-phase-import/import-source-newlines.js test/language/module-code/source-phase-import/import-source-newlines_FIXTURE.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
/*---
44
description: >
55
import source in ImportDeclaration may include line terminators
6+
This test is verified with `import-source.js` in the same directory that
7+
this file does not raise SyntaxError. Note that a SyntaxError could also
8+
be raised when the imported module does not have a source phase
9+
representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
10+
611
esid: sec-modules
712
info: |
813
ImportDeclaration:
@@ -15,7 +20,7 @@ info: |
1520
Source Text Module Record provides a GetModuleSource implementation that always returns an abrupt completion indicating that a source phase import is not available.
1621
negative:
1722
phase: resolution
18-
type: SyntaxError
23+
type: Error
1924
features: [source-phase-imports]
2025
flags: [module]
2126
---*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (C) 2025 Bloomberg LP. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
description: >
6+
Verify that ImportDeclaration can be correctly parsed.
7+
esid: sec-modules
8+
features: [source-phase-imports]
9+
flags: [async]
10+
includes: [asyncHelpers.js]
11+
---*/
12+
13+
function assertImportSourceResolutionFailure(specifier) {
14+
// Import the module and assert that the promise is rejected with a host
15+
// defined error during the resolution phase.
16+
// Note that this is not a `import.source`.
17+
return import(specifier).then(
18+
() => {
19+
throw new Test262Error(`${specifier}: Promise should be rejected`);
20+
},
21+
error => {
22+
print(error)
23+
if (error instanceof SyntaxError) {
24+
throw new Test262Error(`${specifier}: Promise should be rejected with a non-SyntaxError`);
25+
}
26+
}
27+
);
28+
}
29+
30+
asyncTest(async function () {
31+
await assertImportSourceResolutionFailure('./import-source-binding-name_FIXTURE.js');
32+
await assertImportSourceResolutionFailure('./import-source-binding-name-2_FIXTURE.js');
33+
await assertImportSourceResolutionFailure('./import-source-newlines_FIXTURE.js');
34+
});

0 commit comments

Comments
 (0)