mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 06:55:06 +02:00
Remove source phase resolution time negative error types (#4194)
This commit is contained in:
parent
43c45f3b37
commit
74788df072
@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
ImportBinding in ImportDeclaration may be 'source' and 'from'
|
|
||||||
esid: sec-modules
|
|
||||||
info: |
|
|
||||||
ImportDeclaration:
|
|
||||||
import source ImportedBinding FromClause ;
|
|
||||||
|
|
||||||
negative:
|
|
||||||
phase: resolution
|
|
||||||
type: SyntaxError
|
|
||||||
features: [source-phase-imports]
|
|
||||||
flags: [module]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
$DONOTEVALUATE();
|
|
||||||
|
|
||||||
import "../resources/ensure-linking-error_FIXTURE.js";
|
|
||||||
|
|
||||||
import source source from '<do not resolve>';
|
|
||||||
import source from from '<do not resolve>';
|
|
@ -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>';
|
@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
ImportBinding in ImportDeclaration may be 'source' and 'from'
|
|
||||||
esid: sec-modules
|
|
||||||
info: |
|
|
||||||
ImportDeclaration:
|
|
||||||
import source ImportedBinding FromClause ;
|
|
||||||
|
|
||||||
negative:
|
|
||||||
phase: resolution
|
|
||||||
type: SyntaxError
|
|
||||||
features: [source-phase-imports]
|
|
||||||
flags: [module]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
$DONOTEVALUATE();
|
|
||||||
|
|
||||||
import "../resources/ensure-linking-error_FIXTURE.js";
|
|
||||||
|
|
||||||
import source from '<do not resolve>';
|
|
||||||
import from from '<do not resolve>';
|
|
@ -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>';
|
@ -1,31 +0,0 @@
|
|||||||
// Copyright (C) 2024 Chengzhong Wu. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
import source in ImportDeclaration may include line terminators
|
|
||||||
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.
|
|
||||||
negative:
|
|
||||||
phase: resolution
|
|
||||||
type: SyntaxError
|
|
||||||
features: [source-phase-imports]
|
|
||||||
flags: [module]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
$DONOTEVALUATE();
|
|
||||||
|
|
||||||
import "../resources/ensure-linking-error_FIXTURE.js";
|
|
||||||
|
|
||||||
import
|
|
||||||
|
|
||||||
source
|
|
||||||
|
|
||||||
y from '<do not resolve>';
|
|
@ -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>';
|
@ -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');
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user