Skip to content

Commit 74788df

Browse files
authored
Remove source phase resolution time negative error types (#4194)
1 parent 43c45f3 commit 74788df

7 files changed

+96
-77
lines changed

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

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
// ImportBinding in ImportDeclaration may be 'source' and 'from'
5+
// This test is verified with `import-source.js` in the same directory that
6+
// this file does not raise SyntaxError. Note that a SyntaxError could also
7+
// be raised when the imported module does not have a source phase
8+
// representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
9+
//
10+
// esid: sec-modules
11+
// info: |
12+
// ImportDeclaration:
13+
// import source ImportedBinding FromClause ;
14+
15+
import "../resources/ensure-linking-error_FIXTURE.js";
16+
17+
import source source from '<do not resolve>';
18+
import source from from '<do not resolve>';

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

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
// ImportBinding in ImportDeclaration may be 'source' and 'from'
5+
// This test is verified with `import-source.js` in the same directory that
6+
// this file does not raise SyntaxError. Note that a SyntaxError could also
7+
// be raised when the imported module does not have a source phase
8+
// representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
9+
//
10+
// esid: sec-modules
11+
// info:
12+
// ImportDeclaration:
13+
// import source ImportedBinding FromClause ;
14+
15+
import "../resources/ensure-linking-error_FIXTURE.js";
16+
17+
import source from '<do not resolve>';
18+
import from from '<do not resolve>';

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

-31
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
// import source in ImportDeclaration may include line terminators
5+
// This test is verified with `import-source.js` in the same directory that
6+
// this file does not raise SyntaxError. Note that a SyntaxError could also
7+
// be raised when the imported module does not have a source phase
8+
// representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
9+
//
10+
// esid: sec-modules
11+
// info: |
12+
// ImportDeclaration:
13+
// import source ImportedBinding FromClause ;
14+
//
15+
// This test uses all four LineFeed characters in order to completely verify the
16+
// grammar.
17+
//
18+
// 16.2.1.7.2 GetModuleSource ( )
19+
// Source Text Module Record provides a GetModuleSource implementation that always returns an abrupt completion indicating that a source phase import is not available.
20+
21+
import "../resources/ensure-linking-error_FIXTURE.js";
22+
23+
import
24+
25+


source
26+
27+


y from '<do not resolve>';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
if (error instanceof SyntaxError) {
23+
throw new Test262Error(`${specifier}: Promise should be rejected with a non-SyntaxError`);
24+
}
25+
}
26+
);
27+
}
28+
29+
asyncTest(async function () {
30+
await assertImportSourceResolutionFailure('./import-source-binding-name_FIXTURE.js');
31+
await assertImportSourceResolutionFailure('./import-source-binding-name-2_FIXTURE.js');
32+
await assertImportSourceResolutionFailure('./import-source-newlines_FIXTURE.js');
33+
});

0 commit comments

Comments
 (0)