Skip to content

Commit 94cf90e

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

7 files changed

+103
-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,20 @@
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+
$DONOTEVALUATE();
16+
17+
import "../resources/ensure-linking-error_FIXTURE.js";
18+
19+
import source source from '<do not resolve>';
20+
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,20 @@
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+
$DONOTEVALUATE();
16+
17+
import "../resources/ensure-linking-error_FIXTURE.js";
18+
19+
import source from '<do not resolve>';
20+
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,29 @@
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+
$DONOTEVALUATE();
22+
23+
import "../resources/ensure-linking-error_FIXTURE.js";
24+
25+
import
26+
27+


source
28+
29+


y from '<do not resolve>';
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)