mirror of https://github.com/tc39/test262.git
Add tests for export * as ns from mod to dyn imports
This commit is contained in:
parent
3968c2d831
commit
cce2f219f0
|
@ -0,0 +1,60 @@
|
|||
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: >
|
||||
Direct Default exports are 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).
|
||||
[...]
|
||||
features: [export-star-as-namespace-from-module]
|
||||
template: namespace
|
||||
---*/
|
||||
|
||||
//- import
|
||||
import('./get-nested-namespace-dflt-skip-prod_FIXTURE.js')
|
||||
//- body
|
||||
var desc = Object.getOwnPropertyDescriptor(ns, 'productionNS2');
|
||||
|
||||
assert.sameValue(desc.enumerable, true, 'ns.productionNS2: is enumerable');
|
||||
assert.sameValue(desc.writable, true, 'ns.productionNS2: is writable');
|
||||
assert.sameValue(desc.configurable, false, 'ns.productionNS2: is non-configurable');
|
||||
|
||||
var keys = Object.keys(ns.productionNS2);
|
||||
|
||||
assert.sameValue(keys.length, 2);
|
||||
assert.sameValue(keys[0], 'default');
|
||||
assert.sameValue(keys[1], 'productionOther');
|
||||
|
||||
desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'productionOther');
|
||||
|
||||
assert.sameValue(desc.value, null, 'ns.productionNS2.productionOther: value is null');
|
||||
assert.sameValue(desc.enumerable, true, 'ns.productionNS2.productionOther: is enumerable');
|
||||
assert.sameValue(desc.writable, true, 'ns.productionNS2.productionOther: is writable');
|
||||
assert.sameValue(desc.configurable, false, 'ns.productionNS2.productionOther: is non-configurable');
|
||||
|
||||
desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'default');
|
||||
|
||||
assert.sameValue(desc.value, 42, 'ns.productionNS2.default value is 42');
|
||||
assert.sameValue(desc.enumerable, true, 'ns.productionNS2.default is enumerable');
|
||||
assert.sameValue(desc.writable, true, 'ns.productionNS2.default is writable');
|
||||
assert.sameValue(desc.configurable, false, 'ns.productionNS2.default is non-configurable');
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: >
|
||||
Inirect Default exports are 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]
|
||||
features: [export-star-as-namespace-from-module]
|
||||
template: namespace
|
||||
---*/
|
||||
|
||||
//- import
|
||||
import('./get-nested-namespace-dflt-skip-named_FIXTURE.js')
|
||||
//- body
|
||||
var desc = Object.getOwnPropertyDescriptor(ns, 'namedNS2');
|
||||
|
||||
assert.sameValue(desc.enumerable, true, 'ns.namedNS2: is enumerable');
|
||||
assert.sameValue(desc.writable, true, 'ns.namedNS2: is writable');
|
||||
assert.sameValue(desc.configurable, false, 'ns.namedNS2: is non-configurable');
|
||||
|
||||
var keys = Object.keys(ns.namedNS2);
|
||||
|
||||
assert.sameValue(keys.length, 2);
|
||||
assert.sameValue(keys[0], 'default');
|
||||
assert.sameValue(keys[1], 'namedOther');
|
||||
|
||||
desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'namedOther');
|
||||
|
||||
assert.sameValue(desc.value, null, 'ns.namedNS2.namedOther value is null');
|
||||
assert.sameValue(desc.enumerable, true, 'ns.namedNS2.namedOther: is enumerable');
|
||||
assert.sameValue(desc.writable, true, 'ns.namedNS2.namedOther: is writable');
|
||||
assert.sameValue(desc.configurable, false, 'ns.namedNS2.namedOther: is non-configurable');
|
||||
|
||||
desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'default');
|
||||
|
||||
assert.sameValue(desc.value, 42, 'ns.namedNS2.default value is 42');
|
||||
assert.sameValue(desc.enumerable, true, 'ns.namedNS2.default is enumerable');
|
||||
assert.sameValue(desc.writable, true, 'ns.namedNS2.default is writable');
|
||||
assert.sameValue(desc.configurable, false, 'ns.namedNS2.default is non-configurable');
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
desc: >
|
||||
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).
|
||||
features: [export-star-as-namespace-from-module]
|
||||
template: namespace
|
||||
---*/
|
||||
|
||||
//- setup
|
||||
function hasOwnProperty(obj, property) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, property);
|
||||
}
|
||||
|
||||
//- import
|
||||
import('./get-nested-namespace-props-nrml-1_FIXTURE.js')
|
||||
//- body
|
||||
// Export entries defined by a re-exported as exportns module
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsVarDecl'), 'starssVarDecl');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsLetDecl'), 'starSsLetDecl');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsConstDecl'), 'starSsConstDecl');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsFuncDecl'), 'starAsFuncDecl');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsGenDecl'), 'starAsGenDecl');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsClassDecl'), 'starAsClassDecl');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsBindingId'), 'starAsBindingId');
|
||||
assert(hasOwnProperty(ns.exportns, 'starIdName'), 'starIdName');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName'), 'starAsIndirectIdName');
|
||||
assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName2'), 'starAsIndirectIdName2');
|
||||
assert(hasOwnProperty(ns.exportns, 'namespaceBinding'), 'namespaceBinding');
|
||||
|
||||
// Bindings that were not exported from any module
|
||||
assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedVar'), false, 'nonExportedVar');
|
||||
assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedLet'), false, 'nonExportedLet');
|
||||
assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedConst'), false, 'nonExportedConst');
|
||||
assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedFunc'), false, 'nonExportedFunc');
|
||||
assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedGen'), false, 'nonExportedGen');
|
||||
assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedClass'), false, 'nonExportedClass');
|
|
@ -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 = 42;
|
||||
export var namedOther = null;
|
||||
export { x as default };
|
|
@ -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';
|
|
@ -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 42;
|
|
@ -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';
|
|
@ -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';
|
|
@ -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 starAsBindingId;
|
||||
|
||||
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';;
|
|
@ -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 starAsIndirectIdName;
|
Loading…
Reference in New Issue