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
No related branches found
No related tags found
No related merge requests found
Showing
with 178 additions and 25 deletions
...@@ -97,6 +97,10 @@ Intl.RelativeTimeFormat ...@@ -97,6 +97,10 @@ Intl.RelativeTimeFormat
# https://github.com/tc39/proposal-global # https://github.com/tc39/proposal-global
global global
# `export * as namespace from module` consensus PR
# https://github.com/tc39/ecma262/pull/1174
export-star-as-namespace-from-module
# Standard language features # Standard language features
# #
# Language features that have been included in a published version of the # Language features that have been included in a published version of the
......
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-module-semantics-static-semantics-early-errors
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module, export-star-as-namespace-from-module]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
var x;
export { x as z };
export * as z from "early-dup-export-as-star-as.js";
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: sec-module-semantics-static-semantics-early-errors
es6id: 15.2.1.1 es6id: 15.2.1.1
description: > description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any It is a Syntax Error if the ExportedNames of ModuleItemList contains any
......
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-module-semantics-static-semantics-early-errors
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module, export-star-as-namespace-from-module]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
var x;
export default x;
export * as default from 'early-dup-export-start-as-dflt.js';
...@@ -12,7 +12,7 @@ info: | ...@@ -12,7 +12,7 @@ info: |
b. Perform ? requiredModule.ModuleEvaluation(). b. Perform ? requiredModule.ModuleEvaluation().
[...] [...]
includes: [fnGlobalObject.js] includes: [fnGlobalObject.js]
flags: [module] flags: [module, export-star-as-namespace-from-module]
---*/ ---*/
import {} from './eval-rqstd-once_FIXTURE.js'; import {} from './eval-rqstd-once_FIXTURE.js';
...@@ -22,7 +22,8 @@ import dflt1 from './eval-rqstd-once_FIXTURE.js'; ...@@ -22,7 +22,8 @@ import dflt1 from './eval-rqstd-once_FIXTURE.js';
export {} from './eval-rqstd-once_FIXTURE.js'; export {} from './eval-rqstd-once_FIXTURE.js';
import dflt2, {} from './eval-rqstd-once_FIXTURE.js'; import dflt2, {} from './eval-rqstd-once_FIXTURE.js';
export * from './eval-rqstd-once_FIXTURE.js'; export * from './eval-rqstd-once_FIXTURE.js';
import dflt3, * as ns from './eval-rqstd-once_FIXTURE.js'; export * as ns2 from './eval-rqstd-once_FIXTURE.js';
import dflt3, * as ns3 from './eval-rqstd-once_FIXTURE.js';
export default null; export default null;
var global = fnGlobalObject(); var global = fnGlobalObject();
......
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '9';
...@@ -15,10 +15,10 @@ info: | ...@@ -15,10 +15,10 @@ info: |
16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...] [...]
includes: [fnGlobalObject.js] includes: [fnGlobalObject.js]
flags: [module] flags: [module, export-star-as-namespace-from-module]
---*/ ---*/
assert.sameValue(fnGlobalObject().test262, '12345678'); assert.sameValue(fnGlobalObject().test262, '123456789');
import {} from './eval-rqstd-order-1_FIXTURE.js'; import {} from './eval-rqstd-order-1_FIXTURE.js';
...@@ -34,4 +34,6 @@ import dflt2, {} from './eval-rqstd-order-6_FIXTURE.js'; ...@@ -34,4 +34,6 @@ import dflt2, {} from './eval-rqstd-order-6_FIXTURE.js';
export * from './eval-rqstd-order-7_FIXTURE.js'; export * from './eval-rqstd-order-7_FIXTURE.js';
import dflt3, * as ns from './eval-rqstd-order-8_FIXTURE.js'; import dflt3, * as ns2 from './eval-rqstd-order-8_FIXTURE.js';
export * as ns3 from './eval-rqstd-order-9_FIXTURE.js';
...@@ -4,15 +4,24 @@ ...@@ -4,15 +4,24 @@
description: Module is evaluated exactly once description: Module is evaluated exactly once
esid: sec-moduleevaluation esid: sec-moduleevaluation
info: | info: |
Evaluate( ) Concrete Method
[...]
4. Let result be InnerModuleEvaluation(module, stack, 0).
[...]
InnerModuleEvaluation( module, stack, index )
[...]
2. If module.[[Status]] is "evaluated", then
a. If module.[[EvaluationError]] is undefined, return index.
b. Otherwise return module.[[EvaluationError]].
[...] [...]
4. If module.[[Evaluated]] is true, return undefined.
5. Set module.[[Evaluated]] to true.
6. For each String required that is an element of module.[[RequestedModules]] do, 6. For each String required that is an element of module.[[RequestedModules]] do,
a. Let requiredModule be ? HostResolveImportedModule(module, required). a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Perform ? requiredModule.ModuleEvaluation(). [...]
c. Set index to ? InnerModuleEvaluation(requiredModule, stack, index).
[...] [...]
includes: [fnGlobalObject.js] includes: [fnGlobalObject.js]
flags: [module] flags: [module, export-star-as-namespace-from-module]
---*/ ---*/
import {} from './eval-self-once.js'; import {} from './eval-self-once.js';
...@@ -22,6 +31,7 @@ import dflt1 from './eval-self-once.js'; ...@@ -22,6 +31,7 @@ import dflt1 from './eval-self-once.js';
export {} from './eval-self-once.js'; export {} from './eval-self-once.js';
import dflt2, {} from './eval-self-once.js'; import dflt2, {} from './eval-self-once.js';
export * from './eval-self-once.js'; export * from './eval-self-once.js';
export * as ns2 from './eval-self-once.js';
import dflt3, * as ns from './eval-self-once.js'; import dflt3, * as ns from './eval-self-once.js';
export default null; export default null;
......
...@@ -4,20 +4,23 @@ ...@@ -4,20 +4,23 @@
description: Module is instantiated exactly once description: Module is instantiated exactly once
esid: sec-moduledeclarationinstantiation esid: sec-moduledeclarationinstantiation
info: | info: |
Instantiate( ) Concrete Method
[...] [...]
5. If module.[[Environment]] is not undefined, return 4. Let result be InnerModuleInstantiation(module, stack, 0).
NormalCompletion(empty).
6. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]).
7. Set module.[[Environment]] to env.
8. For each String required that is an element of
module.[[RequestedModules]] do,
a. NOTE: Before instantiating a module, all of the modules it requested
must be available. An implementation may perform this test at any
time prior to this point.
b. Let requiredModule be ? HostResolveImportedModule(module, required).
c. Perform ? requiredModule.ModuleDeclarationInstantiation().
[...] [...]
flags: [module]
InnerModuleInstantiation( module, stack, index )
[...]
2. If module.[[Status]] is "instantiating", "instantiated", or "evaluated", then
a. Return index.
3. Assert: module.[[Status]] is "uninstantiated".
4. Set module.[[Status]] to "instantiating".
[...]
9. For each String required that is an element of module.[[RequestedModules]], do
a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Set index to ? InnerModuleInstantiation(requiredModule, stack, index).
[...]
flags: [module, export-star-as-namespace-from-module]
---*/ ---*/
import {} from './instn-once.js'; import {} from './instn-once.js';
...@@ -27,6 +30,7 @@ import dflt1 from './instn-once.js'; ...@@ -27,6 +30,7 @@ import dflt1 from './instn-once.js';
export {} from './instn-once.js'; export {} from './instn-once.js';
import dflt2, {} from './instn-once.js'; import dflt2, {} from './instn-once.js';
export * from './instn-once.js'; export * from './instn-once.js';
export * as ns2 from './instn-once.js';
import dflt3, * as ns from './instn-once.js'; import dflt3, * as ns from './instn-once.js';
export default null; export default null;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: > description: >
An ExportClause without an ExportsList contributes to the list of requested A NamedExport without an ExportsList contributes to the list of requested
modules modules
esid: sec-moduledeclarationinstantiation esid: sec-moduledeclarationinstantiation
info: | info: |
...@@ -25,7 +25,7 @@ info: | ...@@ -25,7 +25,7 @@ info: |
Syntax Syntax
ExportClause: NamedExport:
{ } { }
{ ExportsList } { ExportsList }
{ ExportsList , } { ExportsList , }
......
// 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 module exported with `* as namespace`
esid: sec-moduledeclarationinstantiation
info: |
[...]
4. Let result be InnerModuleInstantiation(module, stack, 0).
[...]
InnerModuleInstantiation( module, stack, index )
[...]
10. Perform ? ModuleDeclarationEnvironmentSetup(module).
[...]
ModuleDeclarationEnvironmentSetup( module )
[...]
c. If in.[[ImportName]] is "*", then
[...]
d. Else,
i. Let resolution be ? importedModule.ResolveExport(in.[[ImportName]], « »).
ii. If resolution is null or "ambiguous", throw a SyntaxError exception.
iii. If resolution.[[BindingName]] is "*namespace*", then
1. Let namespace be ? GetModuleNamespace(resolution.[[Module]]).
[...]
15.2.1.18 Runtime Semantics: GetModuleNamespace
[...]
3. If namespace is undefined, then
a. Let exportedNames be ? module.GetExportedNames(« »).
[...]
15.2.1.16.2 GetExportedNames
[...]
7. For each ExportEntry Record e in module.[[StarExportEntries]], do
[...]
c. For each element n of starNames, do
i. If SameValue(n, "default") is false, then
[...]
flags: [module, export-star-as-namespace-from-module]
---*/
import named from './instn-star-props-dflt-skip-star-as-named_FIXTURE.js';
import production from './instn-star-props-dflt-skip-star-as-prod_FIXTURE.js';
assert('namedOther' in named);
assert.sameValue(
'default' in named, false, 'default specified via identifier'
);
assert('productionOther' in production);
assert.sameValue(
'default' in production, 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.
var x;
export var namedOther = null;
export { x as default };
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export * as named from './instn-star-props-dflt-skip-star-as-named-end_FIXTURE.js';
// 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 production from './instn-star-props-dflt-skip-star-as-prod-end_FIXTURE.js';
...@@ -20,5 +20,7 @@ export { localBindingId }; ...@@ -20,5 +20,7 @@ export { localBindingId };
export { localBindingId as localIdName }; export { localBindingId as localIdName };
export { indirectIdName } from './instn-star-props-nrml-indirect_FIXTURE.js'; export { indirectIdName } from './instn-star-props-nrml-indirect_FIXTURE.js';
export { indirectIdName as indirectIdName2 } from './instn-star-props-nrml-indirect_FIXTURE.js'; export { indirectIdName as indirectIdName2 } from './instn-star-props-nrml-indirect_FIXTURE.js';
export * as namespaceBinding from './instn-star-props-nrml-indirect_FIXTURE.js';
export * from './instn-star-props-nrml-star_FIXTURE.js'; export * from './instn-star-props-nrml-star_FIXTURE.js';
...@@ -20,3 +20,4 @@ export { starBindingId }; ...@@ -20,3 +20,4 @@ export { starBindingId };
export { starBindingId as starIdName }; export { starBindingId as starIdName };
export { starIndirectIdName } from './instn-star-props-nrml-indirect_FIXTURE.js'; export { starIndirectIdName } from './instn-star-props-nrml-indirect_FIXTURE.js';
export { starIndirectIdName as starIndirectIdName2 } from './instn-star-props-nrml-indirect_FIXTURE.js'; export { starIndirectIdName as starIndirectIdName2 } from './instn-star-props-nrml-indirect_FIXTURE.js';
export * as starIndirectNamespaceBinding from './instn-star-props-nrml-indirect_FIXTURE.js';
...@@ -24,7 +24,7 @@ info: | ...@@ -24,7 +24,7 @@ info: |
iii. If resolution is not "ambiguous", append name to iii. If resolution is not "ambiguous", append name to
unambiguousNames. unambiguousNames.
d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames).
flags: [module] flags: [module, export-star-as-namespace-from-module]
---*/ ---*/
import * as ns from './instn-star-props-nrml-1_FIXTURE.js'; import * as ns from './instn-star-props-nrml-1_FIXTURE.js';
...@@ -40,6 +40,7 @@ assert('localBindingId' in ns, 'localBindingId'); ...@@ -40,6 +40,7 @@ assert('localBindingId' in ns, 'localBindingId');
assert('localIdName' in ns, 'localIdName'); assert('localIdName' in ns, 'localIdName');
assert('indirectIdName' in ns, 'indirectIdName'); assert('indirectIdName' in ns, 'indirectIdName');
assert('indirectIdName2' in ns, 'indirectIdName2'); assert('indirectIdName2' in ns, 'indirectIdName2');
assert('namespaceBinding' in ns, 'namespaceBinding');
// Export entries defined by a re-exported module // Export entries defined by a re-exported module
assert('starVarDecl' in ns, 'starVarDecl'); assert('starVarDecl' in ns, 'starVarDecl');
...@@ -52,8 +53,9 @@ assert('starBindingId' in ns, 'starBindingId'); ...@@ -52,8 +53,9 @@ assert('starBindingId' in ns, 'starBindingId');
assert('starIdName' in ns, 'starIdName'); assert('starIdName' in ns, 'starIdName');
assert('starIndirectIdName' in ns, 'starIndirectIdName'); assert('starIndirectIdName' in ns, 'starIndirectIdName');
assert('starIndirectIdName2' in ns, 'starIndirectIdName2'); assert('starIndirectIdName2' in ns, 'starIndirectIdName2');
assert('starIndirectNamespaceBinding' in ns, 'starIndirectNamespaceBinding');
// Bindings that were not exported from either module // Bindings that were not exported from any module
assert.sameValue('nonExportedVar1' in ns, false, 'nonExportedVar1'); assert.sameValue('nonExportedVar1' in ns, false, 'nonExportedVar1');
assert.sameValue('nonExportedVar2' in ns, false, 'nonExportedVar2'); assert.sameValue('nonExportedVar2' in ns, false, 'nonExportedVar2');
assert.sameValue('nonExportedLet1' in ns, false, 'nonExportedLet1'); assert.sameValue('nonExportedLet1' in ns, false, 'nonExportedLet1');
......
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
var x;
export var namedOther = null;
export { x as default };
// Copyright (C) 2018 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export * as namedns2 from './get-nested-namespace-dflt-skip-named-end_FIXTURE.js';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment