Skip to content
Snippets Groups Projects
Commit 2fa8fc40 authored by Valerie Young's avatar Valerie Young Committed by Leo Balter
Browse files

Tests for `export * as ns from 'foo'` syntax (#1498)

parent 358e5e8a
Branches
No related tags found
No related merge requests found
Showing
with 191 additions and 22 deletions
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export var productionOther = null;
export default null;
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export * as productionns2 from './get-nested-namespace-dflt-skip-prod-end_FIXTURE.js';
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default exports are not included in an imported module namespace object when a namespace object is created.
esid: sec-module-namespace-exotic-objects-get-p-receiver
info: |
[...]
6. Let binding be ! m.ResolveExport(P, « »).
7. Assert: binding is a ResolvedBinding Record.
8. Let targetModule be binding.[[Module]].
9. Assert: targetModule is not undefined.
10. If binding.[[BindingName]] is "*namespace*", then
11. Return ? GetModuleNamespace(targetModule).
Runtime Semantics: GetModuleNamespace
[...]
3. If namespace is undefined, then
a. Let exportedNames be ? module.GetExportedNames(« »).
b. Let unambiguousNames be a new empty List.
c. For each name that is an element of exportedNames,
i. Let resolution be ? module.ResolveExport(name, « », « »).
ii. If resolution is null, throw a SyntaxError exception.
iii. If resolution is not "ambiguous", append name to
unambiguousNames.
d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames).
[...]
flags: [module, export-star-as-namespace-from-module]
---*/
import * as namedns1 from './get-nested-namespace-dflt-skip-named_FIXTURE.js';
import * as productionns1 from './get-nested-namespace-dflt-skip-prod_FIXTURE.js';
assert('namedOther' in namedns1.namedns2);
assert.sameValue(
'default' in namedns1.namedns2, false, 'default specified via identifier'
);
assert('productionOther' in productionns1.productionns2);
assert.sameValue(
'default' in productionns1.productionns2, false, 'default specified via dedicated production'
);
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export * as exportns from './get-nested-namespace-props-nrml-2_FIXTURE.js';
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
var notExportedVar;
let notExportedLet;
const notExportedConst = null;
function notExportedFunc() {}
function* notExportedGen() {}
class notExportedClass {}
var starBindingId;
export var starAsVarDecl;
export let starAsLetDecl;
export const starAsConstDecl = null;
export function starAsFuncDecl() {}
export function* starAsGenDecl() {}
export class starAsClassDecl {}
export { starAsBindingId };
export { starAsBindingId as starIdName };
export { starAsIndirectIdName } from './get-nested-namespace-props-nrml-3_FIXTURE.js';
export { starAsIndirectIdName as starAsIndirectIdName2 } from './get-nested-namespace-props-nrml-3_FIXTURE.js';
export * as namespaceBinding from './get-nested-namespace-props-nrml-3_FIXTURE.js';;
// Copyright (C) 2016 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export var indirectIdName;
export var starIndirectIdName;
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Module namespace object reports properties for all ExportEntries of all
dependencies.
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
i. Let namespace be ? GetModuleNamespace(importedModule).
[...]
Runtime Semantics: GetModuleNamespace
3. If namespace is undefined, then
a. Let exportedNames be ? module.GetExportedNames(« »).
b. Let unambiguousNames be a new empty List.
c. For each name that is an element of exportedNames,
i. Let resolution be ? module.ResolveExport(name, « », « »).
ii. If resolution is null, throw a SyntaxError exception.
iii. If resolution is not "ambiguous", append name to
unambiguousNames.
d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames).
flags: [module, export-star-as-namespace-from-module]
---*/
import * as ns from './get-nested-namespace-props-nrml-1_FIXTURE.js';
// Export entries defined by a re-exported as exportns module
assert('starAsVarDecl' in ns.exportns, 'starssVarDecl');
assert('starAsLetDecl' in ns.exportns, 'starSsLetDecl');
assert('starAsConstDecl' in ns.exportns, 'starSsConstDecl');
assert('starAsFuncDecl' in ns.exportns, 'starAsFuncDecl');
assert('starAsGenDecl' in ns.exportns, 'starAsGenDecl');
assert('starAsClassDecl' in ns.exportns, 'starAsClassDecl');
assert('starAsBindingId' in ns.exportns, 'starAsBindingId');
assert('starAsIdName' in ns.exportns, 'starAsIdName');
assert('starAsIndirectIdName' in ns.exportns, 'starAsIndirectIdName');
assert('starAsIndirectIdName2' in ns.exportns, 'starAsIndirectIdName2');
assert('namespaceBinding' in ns.exportns, 'namespaceBinding');
// Bindings that were not exported from any module
assert.sameValue('nonExportedVar' in ns.exportns, false, 'nonExportedVar');
assert.sameValue('nonExportedLet' in ns.exportns, false, 'nonExportedLet');
assert.sameValue('nonExportedConst' in ns.exportns, false, 'nonExportedConst');
assert.sameValue('nonExportedFunc' in ns.exportns, false, 'nonExportedFunc');
assert.sameValue('nonExportedGen' in ns.exportns, false, 'nonExportedGen');
assert.sameValue('nonExportedClass' in ns.exportns, false, 'nonExportedClass');
......@@ -7,8 +7,9 @@ esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......
......@@ -6,9 +6,10 @@ description: >
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * FromClause
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......
......@@ -8,8 +8,9 @@ esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......
......@@ -8,8 +8,9 @@ esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......
......@@ -7,8 +7,9 @@ esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......@@ -17,7 +18,7 @@ info: |
negative:
phase: parse
type: SyntaxError
flags: [module]
flags: [module, export-star-as-namespace-from-module]
---*/
throw "Test262: This statement should not be evaluated.";
......
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export NameSpaceExport FromClause" declarations require a trailing semicolon
or LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead ∉ { function, class }] AssignmentExpression[In];
negative:
phase: parse
type: SyntaxError
flags: [module, export-star-as-namespace-from-module]
---*/
throw "Test262: This statement should not be evaluated.";
export * as namespace from './parse-err-semi-name-space-export.js' null;
......@@ -2,14 +2,15 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export ExportClause FromClause" declarations require a trailing semicolon
"export NamedExports FromClause" declarations require a trailing semicolon
or LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......
......@@ -2,14 +2,15 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
"export ExportClause" declarations require a trailing semicolon or
"export NamedExports" declarations require a trailing semicolon or
LineTerminator
esid: sec-exports
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
......
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: An ExportClause does not require an ExportsList.
description: A NamedExport does not require an ExportsList.
esid: sec-parsemodule
info: |
ExportDeclaration:
export * FromClause;
export ExportClause FromClause;
export ExportClause;
export * as IdentifierName FromClause;
export NamedExports FromClause;
export NamedExports;
export VariableStatement
export Declaration
export default HoistableDeclaration[Default]
export default ClassDeclaration[Default]
export default [lookahead ∉ { function, class }] AssignmentExpression[In];
ExportClause:
NamedExports:
{ }
{ ExportsList }
{ ExportsList , }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment