diff --git a/features.txt b/features.txt index 395ff3aa9386b838f6a5141750ba7d83baaf5daa..e9ca739503987dd4f4f30bd8e2bf4cf86e74a81e 100644 --- a/features.txt +++ b/features.txt @@ -97,6 +97,10 @@ Intl.RelativeTimeFormat # https://github.com/tc39/proposal-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 # # Language features that have been included in a published version of the diff --git a/test/language/module-code/early-dup-export-as-star-as.js b/test/language/module-code/early-dup-export-as-star-as.js new file mode 100644 index 0000000000000000000000000000000000000000..f188fde066aab96aa4cce9fde73e1242469e6a97 --- /dev/null +++ b/test/language/module-code/early-dup-export-as-star-as.js @@ -0,0 +1,18 @@ +// 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"; diff --git a/test/language/module-code/early-dup-export-id-as.js b/test/language/module-code/early-dup-export-id-as.js index 077c9406d42ffe3751c5e0e9650af9b32219d2f3..49b2834b9b0307f74d14e114331d838ec081679e 100644 --- a/test/language/module-code/early-dup-export-id-as.js +++ b/test/language/module-code/early-dup-export-id-as.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // 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 description: > It is a Syntax Error if the ExportedNames of ModuleItemList contains any diff --git a/test/language/module-code/early-dup-export-star-as-dflt.js b/test/language/module-code/early-dup-export-star-as-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..3d8e8ce7871fa9f78b55fc68230d5d150e4700f0 --- /dev/null +++ b/test/language/module-code/early-dup-export-star-as-dflt.js @@ -0,0 +1,18 @@ +// 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'; diff --git a/test/language/module-code/eval-rqstd-once.js b/test/language/module-code/eval-rqstd-once.js index 93a3779be8adc92401439cf3fea1634159c9be7a..b9ddb863ab8cd52ec2e3ad6e5ad8f0d3ce281e4a 100644 --- a/test/language/module-code/eval-rqstd-once.js +++ b/test/language/module-code/eval-rqstd-once.js @@ -12,7 +12,7 @@ info: | b. Perform ? requiredModule.ModuleEvaluation(). [...] includes: [fnGlobalObject.js] -flags: [module] +flags: [module, export-star-as-namespace-from-module] ---*/ import {} 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'; import dflt2, {} 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; var global = fnGlobalObject(); diff --git a/test/language/module-code/eval-rqstd-order-9_FIXTURE.js b/test/language/module-code/eval-rqstd-order-9_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..a4974468a0b6a2451382928a38653f9b36d35c15 --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-9_FIXTURE.js @@ -0,0 +1,4 @@ +// 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'; diff --git a/test/language/module-code/eval-rqstd-order.js b/test/language/module-code/eval-rqstd-order.js index 3d8ca0fdbdbb580b719a7c61f8a08073663e3b53..d15cb55b64324f4c9635b32671bf53442ae00707 100644 --- a/test/language/module-code/eval-rqstd-order.js +++ b/test/language/module-code/eval-rqstd-order.js @@ -15,10 +15,10 @@ info: | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. [...] 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'; @@ -34,4 +34,6 @@ import dflt2, {} from './eval-rqstd-order-6_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'; diff --git a/test/language/module-code/eval-self-once.js b/test/language/module-code/eval-self-once.js index 1da75ae6c097be8ea1195edbd82739cfc46696d2..d6f595dc603201ccaa0be22718654a3ed8d47ef8 100644 --- a/test/language/module-code/eval-self-once.js +++ b/test/language/module-code/eval-self-once.js @@ -4,15 +4,24 @@ description: Module is evaluated exactly once esid: sec-moduleevaluation 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, a. Let requiredModule be ? HostResolveImportedModule(module, required). - b. Perform ? requiredModule.ModuleEvaluation(). + [...] + c. Set index to ? InnerModuleEvaluation(requiredModule, stack, index). [...] includes: [fnGlobalObject.js] -flags: [module] +flags: [module, export-star-as-namespace-from-module] ---*/ import {} from './eval-self-once.js'; @@ -22,6 +31,7 @@ import dflt1 from './eval-self-once.js'; export {} from './eval-self-once.js'; import dflt2, {} 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'; export default null; diff --git a/test/language/module-code/instn-once.js b/test/language/module-code/instn-once.js index dd859ffa5c899e9a57e4b3eefcb1ba4de91cb1bf..040ee3a0cb6e428ad1cfd2493abf2525ad1346ed 100644 --- a/test/language/module-code/instn-once.js +++ b/test/language/module-code/instn-once.js @@ -4,20 +4,23 @@ description: Module is instantiated exactly once esid: sec-moduledeclarationinstantiation info: | + Instantiate( ) Concrete Method [...] - 5. If module.[[Environment]] is not undefined, return - 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(). + 4. Let result be InnerModuleInstantiation(module, stack, 0). [...] -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'; @@ -27,6 +30,7 @@ import dflt1 from './instn-once.js'; export {} from './instn-once.js'; import dflt2, {} from './instn-once.js'; export * from './instn-once.js'; +export * as ns2 from './instn-once.js'; import dflt3, * as ns from './instn-once.js'; export default null; diff --git a/test/language/module-code/instn-resolve-empty-export.js b/test/language/module-code/instn-resolve-empty-export.js index 86b03d3b433567d97a70d04546f10a4c407c7c31..a03f5de672bd748fe5b9f805588a635a95993982 100644 --- a/test/language/module-code/instn-resolve-empty-export.js +++ b/test/language/module-code/instn-resolve-empty-export.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- description: > - An ExportClause without an ExportsList contributes to the list of requested + A NamedExport without an ExportsList contributes to the list of requested modules esid: sec-moduledeclarationinstantiation info: | @@ -25,7 +25,7 @@ info: | Syntax - ExportClause: + NamedExport: { } { ExportsList } { ExportsList , } diff --git a/test/language/module-code/instn-star-as-props-dflt-skip.js b/test/language/module-code/instn-star-as-props-dflt-skip.js new file mode 100644 index 0000000000000000000000000000000000000000..b4532452cc8a29dc32b59b282dd66c6d9c37abe7 --- /dev/null +++ b/test/language/module-code/instn-star-as-props-dflt-skip.js @@ -0,0 +1,57 @@ +// 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' +); diff --git a/test/language/module-code/instn-star-props-dflt-skip-star-as-named-end_FIXTURE.js b/test/language/module-code/instn-star-props-dflt-skip-star-as-named-end_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..0e9f326b22af83d4f71a1986308e1f7b70d153c1 --- /dev/null +++ b/test/language/module-code/instn-star-props-dflt-skip-star-as-named-end_FIXTURE.js @@ -0,0 +1,6 @@ +// 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 }; diff --git a/test/language/module-code/instn-star-props-dflt-skip-star-as-named_FIXTURE.js b/test/language/module-code/instn-star-props-dflt-skip-star-as-named_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..0ffc8fe37f19df4c1c3adb9db82ec56c3030e42e --- /dev/null +++ b/test/language/module-code/instn-star-props-dflt-skip-star-as-named_FIXTURE.js @@ -0,0 +1,4 @@ +// 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'; diff --git a/test/language/module-code/instn-star-props-dflt-skip-star-as-prod-end_FIXTURE.js b/test/language/module-code/instn-star-props-dflt-skip-star-as-prod-end_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..8c21a3362d78fcc7668ffcbd7641728167643692 --- /dev/null +++ b/test/language/module-code/instn-star-props-dflt-skip-star-as-prod-end_FIXTURE.js @@ -0,0 +1,5 @@ +// 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; diff --git a/test/language/module-code/instn-star-props-dflt-skip-star-as-prod_FIXTURE.js b/test/language/module-code/instn-star-props-dflt-skip-star-as-prod_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..530ace997da56c8b91daf0d8c5c85e5afdf66850 --- /dev/null +++ b/test/language/module-code/instn-star-props-dflt-skip-star-as-prod_FIXTURE.js @@ -0,0 +1,4 @@ +// 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'; diff --git a/test/language/module-code/instn-star-props-nrml-1_FIXTURE.js b/test/language/module-code/instn-star-props-nrml-1_FIXTURE.js index 72fe63809cb8f50d08542113156da1b6984057b1..74abc82881647d82502f4562c8b47a8a4b316993 100644 --- a/test/language/module-code/instn-star-props-nrml-1_FIXTURE.js +++ b/test/language/module-code/instn-star-props-nrml-1_FIXTURE.js @@ -20,5 +20,7 @@ export { localBindingId }; export { localBindingId as localIdName }; export { indirectIdName } 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'; + diff --git a/test/language/module-code/instn-star-props-nrml-star_FIXTURE.js b/test/language/module-code/instn-star-props-nrml-star_FIXTURE.js index 6c0d481d68684966ebe5abed8481852295df8eb3..5c1e70dd4eae46e3e60a65b8b4979444116f0d88 100644 --- a/test/language/module-code/instn-star-props-nrml-star_FIXTURE.js +++ b/test/language/module-code/instn-star-props-nrml-star_FIXTURE.js @@ -20,3 +20,4 @@ export { starBindingId }; export { starBindingId as starIdName }; export { starIndirectIdName } 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'; diff --git a/test/language/module-code/instn-star-props-nrml.js b/test/language/module-code/instn-star-props-nrml.js index 615044c0b51aa51a59fded7b24c45654fade175b..3a595536d1823ca4593685a1048f290e47bbdb4f 100644 --- a/test/language/module-code/instn-star-props-nrml.js +++ b/test/language/module-code/instn-star-props-nrml.js @@ -24,7 +24,7 @@ info: | iii. If resolution is not "ambiguous", append name to 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'; @@ -40,6 +40,7 @@ assert('localBindingId' in ns, 'localBindingId'); assert('localIdName' in ns, 'localIdName'); assert('indirectIdName' in ns, 'indirectIdName'); assert('indirectIdName2' in ns, 'indirectIdName2'); +assert('namespaceBinding' in ns, 'namespaceBinding'); // Export entries defined by a re-exported module assert('starVarDecl' in ns, 'starVarDecl'); @@ -52,8 +53,9 @@ assert('starBindingId' in ns, 'starBindingId'); assert('starIdName' in ns, 'starIdName'); assert('starIndirectIdName' in ns, 'starIndirectIdName'); 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('nonExportedVar2' in ns, false, 'nonExportedVar2'); assert.sameValue('nonExportedLet1' in ns, false, 'nonExportedLet1'); diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..0e9f326b22af83d4f71a1986308e1f7b70d153c1 --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js @@ -0,0 +1,6 @@ +// 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 }; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..10732ecc24d71c0734d92780852814de5308e9d9 --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js @@ -0,0 +1,4 @@ +// 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'; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..8c21a3362d78fcc7668ffcbd7641728167643692 --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js @@ -0,0 +1,5 @@ +// 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; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..6687ab1d015be9dadc502dfa40f3a3808537c0ba --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js @@ -0,0 +1,4 @@ +// 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'; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js new file mode 100644 index 0000000000000000000000000000000000000000..c2cb7794ddf2a026a612925d8e95144b1b9bacee --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js @@ -0,0 +1,42 @@ +// 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' +); diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b3ea40c51f4cd00541f58443d364945a9110ba --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js @@ -0,0 +1,4 @@ +// 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'; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-2_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-2_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..2dc945443d7301863b9775bf0d4170a2629cfcef --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-2_FIXTURE.js @@ -0,0 +1,23 @@ +// 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';; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-3_FIXTURE.js b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-3_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..889b984be0132e9a7761ec4dcfbd929a78beef1d --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-3_FIXTURE.js @@ -0,0 +1,5 @@ +// 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; diff --git a/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js new file mode 100644 index 0000000000000000000000000000000000000000..a05b9f2c5d23642df2d16b4b60450e6f5b952f92 --- /dev/null +++ b/test/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js @@ -0,0 +1,51 @@ +// 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'); diff --git a/test/language/module-code/parse-err-export-dflt-expr.js b/test/language/module-code/parse-err-export-dflt-expr.js index 521c3d602da5355b4c541436e16f6e666d3c9a14..e1c8afb7742cc4450aa0956615186843536dd6a0 100644 --- a/test/language/module-code/parse-err-export-dflt-expr.js +++ b/test/language/module-code/parse-err-export-dflt-expr.js @@ -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] diff --git a/test/language/module-code/parse-err-invoke-anon-fun-decl.js b/test/language/module-code/parse-err-invoke-anon-fun-decl.js index a2d4efc4e1d9433e4f128e86f8a772959717449a..eef23aaabeb69e3676d965a2607adafede1bdc66 100644 --- a/test/language/module-code/parse-err-invoke-anon-fun-decl.js +++ b/test/language/module-code/parse-err-invoke-anon-fun-decl.js @@ -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] diff --git a/test/language/module-code/parse-err-invoke-anon-gen-decl.js b/test/language/module-code/parse-err-invoke-anon-gen-decl.js index 6f7dc4d4d17ff1c00200df34501bb6af0a25dfa3..7e4c33d21617df195252502d08921b2ca21a5ba6 100644 --- a/test/language/module-code/parse-err-invoke-anon-gen-decl.js +++ b/test/language/module-code/parse-err-invoke-anon-gen-decl.js @@ -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] diff --git a/test/language/module-code/parse-err-semi-dflt-expr.js b/test/language/module-code/parse-err-semi-dflt-expr.js index 47762c414694e3c92b1d4a3834a4c212bf1c9843..d2f1e59cfcab3da4dfb8e0aca02a3ac3ce950cac 100644 --- a/test/language/module-code/parse-err-semi-dflt-expr.js +++ b/test/language/module-code/parse-err-semi-dflt-expr.js @@ -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] diff --git a/test/language/module-code/parse-err-semi-export-star.js b/test/language/module-code/parse-err-semi-export-star.js index 0222b6fb281d135a6bb417f06bf860ffe1147589..72ff081f6ae2d7279033861132119d662ac13e03 100644 --- a/test/language/module-code/parse-err-semi-export-star.js +++ b/test/language/module-code/parse-err-semi-export-star.js @@ -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."; diff --git a/test/language/module-code/parse-err-semi-name-space-export.js b/test/language/module-code/parse-err-semi-name-space-export.js new file mode 100644 index 0000000000000000000000000000000000000000..f47b498b4e6f288965bbe607d560f66f7f312626 --- /dev/null +++ b/test/language/module-code/parse-err-semi-name-space-export.js @@ -0,0 +1,27 @@ +// 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; diff --git a/test/language/module-code/parse-err-semi-export-clause-from.js b/test/language/module-code/parse-err-semi-named-export-from.js similarity index 80% rename from test/language/module-code/parse-err-semi-export-clause-from.js rename to test/language/module-code/parse-err-semi-named-export-from.js index 3a42aadb83a8a547fb6f90ceeb0312836a42c895..54a145af6669183755265a94a7cdae675fc26ede 100644 --- a/test/language/module-code/parse-err-semi-export-clause-from.js +++ b/test/language/module-code/parse-err-semi-named-export-from.js @@ -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] diff --git a/test/language/module-code/parse-err-semi-export-clause.js b/test/language/module-code/parse-err-semi-named-export.js similarity index 78% rename from test/language/module-code/parse-err-semi-export-clause.js rename to test/language/module-code/parse-err-semi-named-export.js index e744db3dd86cc155c67897f34256bd2dbda4fd1c..501682440dd2910d4582d3204c15f231313a248a 100644 --- a/test/language/module-code/parse-err-semi-export-clause.js +++ b/test/language/module-code/parse-err-semi-named-export.js @@ -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] diff --git a/test/language/module-code/parse-export-empty.js b/test/language/module-code/parse-export-empty.js index fd95dcc3a7235a2ae590706464e22c62b6204810..74cab489bfc1c181b94143a0ae67d614322e83c0 100644 --- a/test/language/module-code/parse-export-empty.js +++ b/test/language/module-code/parse-export-empty.js @@ -1,20 +1,21 @@ // 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 , }