Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove source phase resolution time negative error types #4194

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

// ImportBinding in ImportDeclaration may be 'source' and 'from'
// This test is verified with `import-source.js` in the same directory that
// this file does not raise SyntaxError. Note that a SyntaxError could also
// be raised when the imported module does not have a source phase
// representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
//
// esid: sec-modules
// info: |
// ImportDeclaration:
// import source ImportedBinding FromClause ;

import "../resources/ensure-linking-error_FIXTURE.js";

import source source from '<do not resolve>';
import source from from '<do not resolve>';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

// ImportBinding in ImportDeclaration may be 'source' and 'from'
// This test is verified with `import-source.js` in the same directory that
// this file does not raise SyntaxError. Note that a SyntaxError could also
// be raised when the imported module does not have a source phase
// representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
//
// esid: sec-modules
// info:
// ImportDeclaration:
// import source ImportedBinding FromClause ;

import "../resources/ensure-linking-error_FIXTURE.js";

import source from '<do not resolve>';
import from from '<do not resolve>';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

// import source in ImportDeclaration may include line terminators
// This test is verified with `import-source.js` in the same directory that
// this file does not raise SyntaxError. Note that a SyntaxError could also
// be raised when the imported module does not have a source phase
// representation (see sec-source-text-module-record-initialize-environment, 7.c.ii).
//
// esid: sec-modules
// info: |
// ImportDeclaration:
// import source ImportedBinding FromClause ;
//
// This test uses all four LineFeed characters in order to completely verify the
// grammar.
//
// 16.2.1.7.2 GetModuleSource ( )
// Source Text Module Record provides a GetModuleSource implementation that always returns an abrupt completion indicating that a source phase import is not available.

import "../resources/ensure-linking-error_FIXTURE.js";

import



source



y from '<do not resolve>';
33 changes: 33 additions & 0 deletions test/language/module-code/source-phase-import/import-source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) 2025 Bloomberg LP. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
Verify that ImportDeclaration can be correctly parsed.
esid: sec-modules
features: [source-phase-imports]
flags: [async]
includes: [asyncHelpers.js]
---*/

function assertImportSourceResolutionFailure(specifier) {
// Import the module and assert that the promise is rejected with a host
// defined error during the resolution phase.
// Note that this is not a `import.source`.
return import(specifier).then(
() => {
throw new Test262Error(`${specifier}: Promise should be rejected`);
},
error => {
if (error instanceof SyntaxError) {
throw new Test262Error(`${specifier}: Promise should be rejected with a non-SyntaxError`);
}
}
);
}

asyncTest(async function () {
await assertImportSourceResolutionFailure('./import-source-binding-name_FIXTURE.js');
await assertImportSourceResolutionFailure('./import-source-binding-name-2_FIXTURE.js');
await assertImportSourceResolutionFailure('./import-source-newlines_FIXTURE.js');
});