diff options
Diffstat (limited to 'js/src/tests/test262/language/module-code/namespace/internals')
44 files changed, 1508 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/module-code/namespace/internals/browser.js b/js/src/tests/test262/language/module-code/namespace/internals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/browser.js diff --git a/js/src/tests/test262/language/module-code/namespace/internals/define-own-property.js b/js/src/tests/test262/language/module-code/namespace/internals/define-own-property.js new file mode 100644 index 0000000000..bb3f73fe0e --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/define-own-property.js @@ -0,0 +1,140 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc +description: > + The [[DefineOwnProperty]] internal method returns `true` if no change is + requested, and `false` otherwise. +flags: [module] +features: [Symbol.iterator, Reflect, Symbol, Symbol.toStringTag] +---*/ + +import * as ns from './define-own-property.js'; +export var local1; +var local2; +export { local2 as renamed }; +export { local1 as indirect } from './define-own-property.js'; +var sym = Symbol('test262'); + +const exported = ['local1', 'renamed', 'indirect']; + + +// Non-existant properties. + +for (const key of ['local2', 0, sym, Symbol.iterator]) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + false, + 'Reflect.defineProperty: ' + key.toString() + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {}); + }, 'Object.defineProperty: ' + key.toString()); +} + + +// Own properties. No change requested. + +for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + true, + 'Reflect.defineProperty: ' + key.toString() + ); + assert.sameValue( + Object.defineProperty(ns, key, {}), + ns, + 'Object.defineProperty: ' + key.toString() + ); + +} + +assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + true, + 'Reflect.defineProperty: indirect' +); +assert.sameValue( + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + ns, + 'Object.defineProperty: indirect' +); + +assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + true, + 'Reflect.defineProperty: Symbol.toStringTag' +); +assert.sameValue( + Object.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + ns, + 'Object.defineProperty: Symbol.toStringTag' +); + + +// Own properties. Change requested. + +for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {value: 123}), + false, + 'Reflect.defineProperty: ' + key.toString() + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {value: 123}); + }, 'Object.defineProperty: ' + key.toString()); +} + +assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}), + false, + 'Reflect.defineProperty: indirect' +); +assert.throws(TypeError, function() { + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}); +}, 'Object.defineProperty: indirect'); + +assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}), + false, + 'Reflect.defineProperty: Symbol.toStringTag' +); +assert.throws(TypeError, function() { + Object.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}); +}, 'Object.defineProperty: Symbol.toStringTag'); + + +// Indirect change requested through Object.freeze + +// Try freezing more times than there are exported properties +for (let i = 1; i < exported.length + 2; i++) { + assert.throws( + TypeError, + function () { + Object.freeze(ns); + }, + "Object.freeze: " + String(i) + ); +} + +for (const key of exported) { + const desc = Object.getOwnPropertyDescriptor(ns, key); + assert.sameValue(desc.writable, true, String(key) + " writable"); +} + +assert(!Object.isFrozen(ns), "namespace object not frozen"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/delete-exported-init.js b/js/src/tests/test262/language/module-code/namespace/internals/delete-exported-init.js new file mode 100644 index 0000000000..e39fded73a --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/delete-exported-init.js @@ -0,0 +1,49 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +description: > + [[Delete]] behavior for a key that describes an initialized exported + binding +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return false. +flags: [module] +features: [Reflect] +---*/ + +import * as ns from './delete-exported-init.js'; +export var local1 = 333; +var local2 = 444; +export { local2 as renamed }; +export { local1 as indirect } from './delete-exported-init.js'; + +assert.throws(TypeError, function() { + delete ns.local1; +}, 'delete: local1'); +assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' +); +assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + +assert.throws(TypeError, function() { + delete ns.renamed; +}, 'delete: renamed'); +assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' +); +assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + +assert.throws(TypeError, function() { + delete ns.indirect; +}, 'delete: indirect'); +assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' +); +assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/delete-exported-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/delete-exported-uninit.js new file mode 100644 index 0000000000..c32997b35d --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/delete-exported-uninit.js @@ -0,0 +1,69 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +description: > + [[Delete]] behavior for a key that describes an uninitialized exported + binding +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return false. +flags: [module] +features: [Reflect, let] +---*/ + +import * as ns from './delete-exported-uninit.js'; + +assert.throws(TypeError, function() { + delete ns.local1; +}, 'delete: local1'); +assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' +); +assert.throws(ReferenceError, function() { + ns.local1; +}, 'binding unmodified: local1'); + +assert.throws(TypeError, function() { + delete ns.renamed; +}, 'delete: renamed'); +assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' +); +assert.throws(ReferenceError, function() { + ns.renamed; +}, 'binding unmodified: renamed'); + +assert.throws(TypeError, function() { + delete ns.indirect; +}, 'delete: indirect'); +assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' +); +assert.throws(ReferenceError, function() { + ns.indirect; +}, 'binding unmodified: indirect'); + +assert.throws(TypeError, function() { + delete ns.default; +}, 'delete: default'); +assert.sameValue( + Reflect.deleteProperty(ns, 'default'), + false, + 'Reflect.deleteProperty: default' +); +assert.throws(ReferenceError, function() { + ns.default; +}, 'binding unmodified: default'); + +export let local1 = 23; +let local2 = 45; +export { local2 as renamed }; +export { local1 as indirect } from './delete-exported-uninit.js'; +export default null; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/delete-non-exported.js b/js/src/tests/test262/language/module-code/namespace/internals/delete-non-exported.js new file mode 100644 index 0000000000..b7d13bc747 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/delete-non-exported.js @@ -0,0 +1,39 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +description: > + [[Delete]] behavior for a key that does not describe an exported binding +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. +flags: [module] +features: [Reflect, Symbol, Symbol.toStringTag] +---*/ + +import * as ns from './delete-non-exported.js'; +var sym = Symbol('test262'); + +assert(delete ns.undef, 'delete: undef'); +assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + +assert(delete ns.default, 'delete: default'); +assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' +); + +assert.throws(TypeError, function() { delete ns[Symbol.toStringTag]; }, 'delete: Symbol.toStringTag'); +assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' +); + +assert(delete ns[sym], 'delete: symbol'); +assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/enumerate-binding-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/enumerate-binding-uninit.js new file mode 100644 index 0000000000..ee8107ebc4 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/enumerate-binding-uninit.js @@ -0,0 +1,45 @@ +// |reftest| module +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-enumerate-object-properties +description: > + Test for-in enumeration with uninitialized binding. +info: | + 13.7.5.15 EnumerateObjectProperties (O) + ... + EnumerateObjectProperties must obtain the own property keys of the + target object by calling its [[OwnPropertyKeys]] internal method. + Property attributes of the target object must be obtained by + calling its [[GetOwnProperty]] internal method. + + 9.4.6.4 [[GetOwnProperty]] (P) + ... + 4. Let value be ? O.[[Get]](P, O). + ... + + 9.4.6.7 [[Get]] (P, Receiver) + ... + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + + 8.1.1.1.6 GetBindingValue ( N, S ) + ... + If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception. + ... + +flags: [module] +---*/ + +import* as self from "./enumerate-binding-uninit.js"; + +assert.throws(ReferenceError, function() { + for (var key in self) { + throw new Test262Error(); + } +}); + +export default 0; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js new file mode 100644 index 0000000000..28d0220546 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js @@ -0,0 +1,7 @@ +// |reftest| skip -- not a test file +// 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/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js new file mode 100644 index 0000000000..9967b92744 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js @@ -0,0 +1,5 @@ +// |reftest| skip -- not a test file +// 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/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js new file mode 100644 index 0000000000..2b837fe225 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js @@ -0,0 +1,6 @@ +// |reftest| skip -- not a test file +// 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/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js new file mode 100644 index 0000000000..927338724b --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js @@ -0,0 +1,5 @@ +// |reftest| skip -- not a test file +// 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/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js new file mode 100644 index 0000000000..41bb7933bb --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js @@ -0,0 +1,46 @@ +// |reftest| module +// 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 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] +---*/ + +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, true, 'default specified via identifier' +); + +assert('productionOther' in productionns1.productionns2); +assert.sameValue( + 'default' in productionns1.productionns2, true, 'default specified via dedicated production' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js new file mode 100644 index 0000000000..3eb0886e15 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js @@ -0,0 +1,5 @@ +// |reftest| skip -- not a test file +// 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/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-2_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-2_FIXTURE.js new file mode 100644 index 0000000000..7ec2cc2b4c --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-2_FIXTURE.js @@ -0,0 +1,24 @@ +// |reftest| skip -- not a test file +// 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';; diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-3_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-3_FIXTURE.js new file mode 100644 index 0000000000..11ccdef663 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml-3_FIXTURE.js @@ -0,0 +1,6 @@ +// |reftest| skip -- not a test file +// 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; diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js new file mode 100644 index 0000000000..e6e52de774 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js @@ -0,0 +1,55 @@ +// |reftest| module +// 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] +features: [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('starIdName' in ns.exportns, 'starIdName'); +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'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-found-init.js b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-found-init.js new file mode 100644 index 0000000000..148a12b6cd --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-found-init.js @@ -0,0 +1,63 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +description: > + Behavior of the [[GetOwnProperty]] internal method with a string argument + describing an initialized binding +info: | + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). + 5. Return PropertyDescriptor{[[Value]]: value, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: false }. +flags: [module] +---*/ + +import * as ns from './get-own-property-str-found-init.js'; +export var local1 = 201; +var local2 = 207; +export { local2 as renamed }; +export { local1 as indirect } from './get-own-property-str-found-init.js'; +export default 302; +var desc; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local1'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); +assert.sameValue(desc.value, 201); +assert.sameValue(desc.enumerable, true, 'local1 enumerable'); +assert.sameValue(desc.writable, true, 'local1 writable'); +assert.sameValue(desc.configurable, false, 'local1 configurable'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'renamed'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); +assert.sameValue(desc.value, 207); +assert.sameValue(desc.enumerable, true, 'renamed enumerable'); +assert.sameValue(desc.writable, true, 'renamed writable'); +assert.sameValue(desc.configurable, false, 'renamed configurable'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'indirect'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); +assert.sameValue(desc.value, 201); +assert.sameValue(desc.enumerable, true, 'indirect enumerable'); +assert.sameValue(desc.writable, true, 'indirect writable'); +assert.sameValue(desc.configurable, false, 'indirect configurable'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'default'); +assert.sameValue(desc.value, 302); +assert.sameValue(desc.enumerable, true, 'default enumerable'); +assert.sameValue(desc.writable, true, 'default writable'); +assert.sameValue(desc.configurable, false, 'default configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-found-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-found-uninit.js new file mode 100644 index 0000000000..0060850171 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-found-uninit.js @@ -0,0 +1,54 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +description: > + Behavior of the [[GetOwnProperty]] internal method with a string argument + describing an uninitialized binding +info: | + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). +flags: [module] +features: [let] +---*/ + +import * as ns from './get-own-property-str-found-uninit.js'; + +assert.throws(ReferenceError, function() { + Object.prototype.hasOwnProperty.call(ns, 'local1'); +}, 'hasOwnProperty: local1'); +assert.throws(ReferenceError, function() { + Object.getOwnPropertyDescriptor(ns, 'local1'); +}, 'getOwnPropertyDescriptor: local1'); + +assert.throws(ReferenceError, function() { + Object.prototype.hasOwnProperty.call(ns, 'renamed'); +}, 'hasOwnProperty: renamed'); +assert.throws(ReferenceError, function() { + Object.getOwnPropertyDescriptor(ns, 'renamed'); +}, 'getOwnPropertyDescriptor: renamed'); + +assert.throws(ReferenceError, function() { + Object.prototype.hasOwnProperty.call(ns, 'indirect'); +}, 'hasOwnProperty: indirect'); +assert.throws(ReferenceError, function() { + Object.getOwnPropertyDescriptor(ns, 'indirect'); +}, 'getOwnPropertyDescriptor: indirect'); + +assert.throws(ReferenceError, function() { + Object.prototype.hasOwnProperty.call(ns, 'default'); +}, 'hasOwnProperty: default'); +assert.throws(ReferenceError, function() { + Object.getOwnPropertyDescriptor(ns, 'default'); +}, 'getOwnPropertyDescriptor: default'); + +export let local1 = 23; +let local2 = 45; +export { local2 as renamed }; +export { local1 as indirect } from './get-own-property-str-found-uninit.js'; +export default null; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-not-found.js b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-not-found.js new file mode 100644 index 0000000000..0a2c9e4460 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-str-not-found.js @@ -0,0 +1,69 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +description: > + Behavior of the [[GetOwnProperty]] internal method with a string argument + describing a binding that cannot be found +info: | + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. +flags: [module] +---*/ + +import * as ns from './get-own-property-str-not-found.js'; +var test262; +export { test262 as anotherName }; +var desc; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'test262'), + false, + 'hasOwnProperty: test262' +); +desc = Object.getOwnPropertyDescriptor(ns, 'test262'); +assert.sameValue(desc, undefined, 'property descriptor for "test262"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'desc'), + false, + 'hasOwnProperty: desc' +); +desc = Object.getOwnPropertyDescriptor(ns, 'desc'); +assert.sameValue(desc, undefined, 'property descriptor for "desc"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'toStringTag'), + false, + 'hasOwnProperty: toStringTag' +); +desc = Object.getOwnPropertyDescriptor(ns, 'toStringTag'); +assert.sameValue(desc, undefined, 'property descriptor for "toStringTag"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'iterator'), + false, + 'hasOwnProperty: iterator' +); +desc = Object.getOwnPropertyDescriptor(ns, 'iterator'); +assert.sameValue(desc, undefined, 'property descriptor for "iterator"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, '__proto__'), + false, + 'hasOwnProperty: __proto__' +); +desc = Object.getOwnPropertyDescriptor(ns, '__proto__'); +assert.sameValue(desc, undefined, 'property descriptor for "__proto__"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), + false, + 'hasOwnProperty: default' +); +desc = Object.getOwnPropertyDescriptor(ns, 'default'); +assert.sameValue(desc, undefined, 'property descriptor for "default"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-sym.js b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-sym.js new file mode 100644 index 0000000000..491b235217 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-own-property-sym.js @@ -0,0 +1,29 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +description: > + Behavior of the [[GetOwnProperty]] internal method with a Symbol argument +flags: [module] +features: [Symbol, Symbol.toStringTag] +---*/ + +import * as ns from './get-own-property-sym.js'; +var notFound = Symbol('test262'); +var desc; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, Symbol.toStringTag), true +); +desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); +assert.sameValue(desc.value, ns[Symbol.toStringTag]); +assert.sameValue(desc.enumerable, false, 'Symbol.toStringTag enumerable'); +assert.sameValue(desc.writable, false, 'Symbol.toStringTag writable'); +assert.sameValue(desc.configurable, false, 'Symbol.toStringTag configurable'); + +assert.sameValue(Object.prototype.hasOwnProperty.call(ns, notFound), false); +desc = Object.getOwnPropertyDescriptor(ns, notFound); +assert.sameValue(desc, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-prototype-of.js b/js/src/tests/test262/language/module-code/namespace/internals/get-prototype-of.js new file mode 100644 index 0000000000..6345aa901d --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-prototype-of.js @@ -0,0 +1,15 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getprototypeof +description: The [[GetPrototypeOf]] internal method returns `null` +flags: [module] +---*/ + +import * as ns from './get-prototype-of.js'; + +assert.sameValue(ns instanceof Object, false); +assert.sameValue(Object.getPrototypeOf(ns), null); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-str-found-init.js b/js/src/tests/test262/language/module-code/namespace/internals/get-str-found-init.js new file mode 100644 index 0000000000..b86b23ef6a --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-str-found-init.js @@ -0,0 +1,28 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: > + Behavior of the [[Get]] internal method with a string argument for exported + initialized bindings. +info: | + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). +flags: [module] +---*/ + +import * as ns from './get-str-found-init.js'; +export var local1 = 23; +var local2 = 45; +export { local2 as renamed }; +export { local1 as indirect } from './get-str-found-init.js'; +export default 444; + +assert.sameValue(ns.local1, 23); +assert.sameValue(ns.renamed, 45); +assert.sameValue(ns.indirect, 23); +assert.sameValue(ns.default, 444); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-str-found-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/get-str-found-uninit.js new file mode 100644 index 0000000000..384c09599c --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-str-found-uninit.js @@ -0,0 +1,38 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: > + Behavior of the [[Get]] internal method with a string argument for exported + uninitialized bindings. +info: | + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). +flags: [module] +features: [let] +---*/ + +import * as ns from './get-str-found-uninit.js'; + +assert.throws(ReferenceError, function() { + ns.local1; +}); +assert.throws(ReferenceError, function() { + ns.renamed; +}); +assert.throws(ReferenceError, function() { + ns.indirect; +}); +assert.throws(ReferenceError, function() { + ns.default; +}); + +export let local1 = 23; +let local2 = 45; +export { local2 as renamed }; +export { local1 as indirect } from './get-str-found-uninit.js'; +export default null; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-str-initialize.js b/js/src/tests/test262/language/module-code/namespace/internals/get-str-initialize.js new file mode 100644 index 0000000000..3eb6b82084 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-str-initialize.js @@ -0,0 +1,28 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: > + References observe the initialization of lexical bindings +info: | + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). +flags: [module] +features: [let] +---*/ + +import * as ns from './get-str-initialize.js'; +export let localUninit1 = 111; +let localUninit2 = 222; +export { localUninit2 as renamedUninit }; +export { localUninit1 as indirectUninit } from './get-str-initialize.js'; +export default 333; + +assert.sameValue(ns.localUninit1, 111); +assert.sameValue(ns.renamedUninit, 222); +assert.sameValue(ns.indirectUninit, 111); +assert.sameValue(ns.default, 333); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-str-not-found.js b/js/src/tests/test262/language/module-code/namespace/internals/get-str-not-found.js new file mode 100644 index 0000000000..8ced7ffb78 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-str-not-found.js @@ -0,0 +1,26 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: > + Behavior of the [[Get]] internal method with a string argument for + non-exported bindings +info: | + [...] + 3. Let exports be the value of O's [[Exports]] internal slot. + 4. If P is not an element of exports, return undefined. +flags: [module] +---*/ + +import * as ns from './get-str-not-found.js'; +var test262; +export { test262 as anotherName }; + +assert.sameValue(ns.test262, undefined, 'key: test262'); +assert.sameValue(ns.toStringTag, undefined, 'key: toStringTag'); +assert.sameValue(ns.iterator, undefined, 'key: iterator'); +assert.sameValue(ns.__proto__, undefined, 'key: __proto__'); +assert.sameValue(ns.default, undefined, 'key: default'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-str-update.js b/js/src/tests/test262/language/module-code/namespace/internals/get-str-update.js new file mode 100644 index 0000000000..23dba1d489 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-str-update.js @@ -0,0 +1,27 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: References observe the mutation of initialized bindings +info: | + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). +flags: [module] +---*/ + +import * as ns from './get-str-update.js'; +export var local1 = 111; +var local2 = 222; +export { local2 as renamed }; +export { local1 as indirect } from './get-str-update.js'; + +local1 = 333; +local2 = 444; + +assert.sameValue(ns.local1, 333); +assert.sameValue(ns.renamed, 444); +assert.sameValue(ns.indirect, 333); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-sym-found.js b/js/src/tests/test262/language/module-code/namespace/internals/get-sym-found.js new file mode 100644 index 0000000000..628d053b1a --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-sym-found.js @@ -0,0 +1,21 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: > + Behavior of the [[Get]] internal method with a symbol argument that can be + found +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). +flags: [module] +features: [Symbol.toStringTag] +---*/ + +import * as ns from './get-sym-found.js'; + +assert.sameValue(typeof ns[Symbol.toStringTag], 'string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/get-sym-not-found.js b/js/src/tests/test262/language/module-code/namespace/internals/get-sym-not-found.js new file mode 100644 index 0000000000..61e9b7a6f1 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/get-sym-not-found.js @@ -0,0 +1,21 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +description: > + Behavior of the [[Get]] internal method with a symbol argument that cannot + be found +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). +flags: [module] +features: [Symbol] +---*/ + +import * as ns from './get-sym-not-found.js'; + +assert.sameValue(ns[Symbol('test262')], undefined, 'Symbol: test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-found-init.js b/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-found-init.js new file mode 100644 index 0000000000..3dc01c249e --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-found-init.js @@ -0,0 +1,36 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +description: > + Behavior of the [[HasProperty]] internal method with a string argument for + exported initialized bindings. +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. +flags: [module] +features: [Reflect] +---*/ + +import * as ns from './has-property-str-found-init.js'; +export var local1; +var local2; +export { local2 as renamed }; +export { local1 as indirect } from './has-property-str-found-init.js'; +export default null; + +assert('local1' in ns, 'in: local1'); +assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + +assert('renamed' in ns, 'in: renamed'); +assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + +assert('indirect' in ns, 'in: indirect'); +assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + +assert('default' in ns, 'in: default'); +assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-found-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-found-uninit.js new file mode 100644 index 0000000000..c939fda03b --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-found-uninit.js @@ -0,0 +1,38 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +description: > + Behavior of the [[HasProperty]] internal method with a string argument for + exported uninitialized bindings. +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. +flags: [module] +features: [Reflect, let] +---*/ + +import * as ns from './has-property-str-found-uninit.js'; + +assert('local1' in ns, 'in: local1'); +assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + +assert('renamed' in ns, 'in: renamed'); +assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + +assert('indirect' in ns, 'in: indirect'); +assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + +assert('default' in ns, 'in: default'); +assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); + +export let local1 = 23; +let local2 = 45; +export { local2 as renamed }; +export { local1 as indirect } from './has-property-str-found-uninit.js'; +export default null; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-not-found.js b/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-not-found.js new file mode 100644 index 0000000000..88665db1be --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/has-property-str-not-found.js @@ -0,0 +1,41 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +description: > + Behavior of the [[HasProperty]] internal method with a string argument for + non-exported bindings +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. +flags: [module] +features: [Reflect] +---*/ + +import * as ns from './has-property-str-not-found.js'; +var test262; +export { test262 as anotherName }; + +assert.sameValue('test262' in ns, false, 'in: test262'); +assert.sameValue(Reflect.has(ns, 'test262'), false, 'Reflect.has: test262'); + +assert.sameValue('toStringTag' in ns, false, 'in: toStringTag'); +assert.sameValue( + Reflect.has(ns, 'toStringTag'), false, 'Reflect.has: toStringTag' +); + +assert.sameValue('iterator' in ns, false, 'in: iterator'); +assert.sameValue(Reflect.has(ns, 'iterator'), false, 'Reflect.has: iterator'); + +assert.sameValue('__proto__' in ns, false, 'in: __proto__'); +assert.sameValue( + Reflect.has(ns, '__proto__'), false, 'Reflect.has: __proto__' +); + +assert.sameValue('default' in ns, false, 'in: default'); +assert.sameValue(Reflect.has(ns, 'default'), false, 'Reflect.has: default'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/has-property-sym-found.js b/js/src/tests/test262/language/module-code/namespace/internals/has-property-sym-found.js new file mode 100644 index 0000000000..df79504219 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/has-property-sym-found.js @@ -0,0 +1,20 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +description: > + Behavior of the [[HasProperty]] internal method with a symbol argument that + can be found +info: | + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). +flags: [module] +features: [Symbol.toStringTag, Reflect] +---*/ + +import * as ns from './has-property-sym-found.js'; + +assert(Symbol.toStringTag in ns, 'in: Symbol.toStringTag'); +assert(Reflect.has(ns, Symbol.toStringTag), 'Reflect.has: Symbol.toStringTag'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/has-property-sym-not-found.js b/js/src/tests/test262/language/module-code/namespace/internals/has-property-sym-not-found.js new file mode 100644 index 0000000000..f15464b71b --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/has-property-sym-not-found.js @@ -0,0 +1,21 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +description: > + Behavior of the [[HasProperty]] internal method with a symbol argument that + cannot be found +info: | + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). +flags: [module] +features: [Symbol, Reflect] +---*/ + +import * as ns from './has-property-sym-not-found.js'; +var sym = Symbol('test262'); + +assert.sameValue(sym in ns, false, 'in'); +assert.sameValue(Reflect.has(ns, sym), false, 'Reflect.has'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/is-extensible.js b/js/src/tests/test262/language/module-code/namespace/internals/is-extensible.js new file mode 100644 index 0000000000..6e1d024d7c --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/is-extensible.js @@ -0,0 +1,14 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-isextensible +description: The [[IsExtensible]] internal method returns `false` +flags: [module] +---*/ + +import * as ns from './is-extensible.js'; + +assert.sameValue(Object.isExtensible(ns), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/object-hasOwnProperty-binding-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/object-hasOwnProperty-binding-uninit.js new file mode 100644 index 0000000000..8d496b756c --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/object-hasOwnProperty-binding-uninit.js @@ -0,0 +1,45 @@ +// |reftest| module +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.hasownproperty +description: > + Test Object.prototype.hasOwnProperty() with uninitialized binding. +info: | + 19.1.3.2 Object.prototype.hasOwnProperty ( V ) + ... + 3. Return ? HasOwnProperty(O, P). + + 7.3.11 HasOwnProperty ( O, P ) + ... + 3. Let desc be ? O.[[GetOwnProperty]](P). + ... + + 9.4.6.4 [[GetOwnProperty]] (P) + ... + 4. Let value be ? O.[[Get]](P, O). + ... + + 9.4.6.7 [[Get]] (P, Receiver) + ... + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + + 8.1.1.1.6 GetBindingValue ( N, S ) + ... + If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception. + ... + +flags: [module] +---*/ + +import* as self from "./object-hasOwnProperty-binding-uninit.js"; + +assert.throws(ReferenceError, function() { + Object.prototype.hasOwnProperty.call(self, "default"); +}); + +export default 0; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/object-keys-binding-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/object-keys-binding-uninit.js new file mode 100644 index 0000000000..67d9a75997 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/object-keys-binding-uninit.js @@ -0,0 +1,48 @@ +// |reftest| module +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.keys +description: > + Test Object.keys() with uninitialized binding. +info: | + 19.1.2.16 Object.keys ( O ) + ... + 2. Let nameList be ? EnumerableOwnProperties(obj, "key"). + ... + + 7.3.21 EnumerableOwnProperties ( O, kind ) + ... + 4. For each element key of ownKeys in List order, do + a. If Type(key) is String, then + i. Let desc be ? O.[[GetOwnProperty]](key). + ... + + 9.4.6.4 [[GetOwnProperty]] (P) + ... + 4. Let value be ? O.[[Get]](P, O). + ... + + 9.4.6.7 [[Get]] (P, Receiver) + ... + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + + 8.1.1.1.6 GetBindingValue ( N, S ) + ... + If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception. + ... + +flags: [module] +---*/ + +import* as self from "./object-keys-binding-uninit.js"; + +assert.throws(ReferenceError, function() { + Object.keys(self); +}); + +export default 0; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/object-propertyIsEnumerable-binding-uninit.js b/js/src/tests/test262/language/module-code/namespace/internals/object-propertyIsEnumerable-binding-uninit.js new file mode 100644 index 0000000000..be5f6ea39e --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/object-propertyIsEnumerable-binding-uninit.js @@ -0,0 +1,41 @@ +// |reftest| module +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.prototype.propertyisenumerable +description: > + Test Object.prototype.propertyIsEnumerable() with uninitialized binding. +info: | + 19.1.3.4 Object.prototype.propertyIsEnumerable ( V ) + ... + 3. Let desc be ? O.[[GetOwnProperty]](P). + ... + + 9.4.6.4 [[GetOwnProperty]] (P) + ... + 4. Let value be ? O.[[Get]](P, O). + ... + + 9.4.6.7 [[Get]] (P, Receiver) + ... + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + + 8.1.1.1.6 GetBindingValue ( N, S ) + ... + If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception. + ... + +flags: [module] +---*/ + +import* as self from "./object-propertyIsEnumerable-binding-uninit.js"; + +assert.throws(ReferenceError, function() { + Object.prototype.propertyIsEnumerable.call(self, "default"); +}); + +export default 0; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-binding-types.js b/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-binding-types.js new file mode 100644 index 0000000000..9f196cfb9d --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-binding-types.js @@ -0,0 +1,81 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-ownpropertykeys +description: > + The [[OwnPropertyKeys]] internal method includes entries for all binding + types +info: | + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. + + Note: identifiers have been selected such that runtimes which do not sort + the [[Exports]] list may still pass. A separate test is dedicated to sort + order. +flags: [module] +features: [Reflect, Symbol.toStringTag, let] +---*/ + +import * as ns from './own-property-keys-binding-types.js'; +export var a_local1; +var local2; +export { local2 as b_renamed }; +export { a_local1 as e_indirect } from './own-property-keys-binding-types.js'; +export * from './own-property-keys-binding-types_FIXTURE.js'; + +var stringKeys = Object.getOwnPropertyNames(ns); + +assert.sameValue(stringKeys.length, 10); +assert.sameValue(stringKeys[0], 'a_local1'); +assert.sameValue(stringKeys[1], 'b_renamed'); +assert.sameValue(stringKeys[2], 'c_localUninit1'); +assert.sameValue(stringKeys[3], 'd_renamedUninit'); +assert.sameValue(stringKeys[4], 'default'); +assert.sameValue(stringKeys[5], 'e_indirect'); +assert.sameValue(stringKeys[6], 'f_indirectUninit'); +assert.sameValue(stringKeys[7], 'g_star'); +assert.sameValue(stringKeys[8], 'h_starRenamed'); +assert.sameValue(stringKeys[9], 'i_starIndirect'); + +var symbolKeys = Object.getOwnPropertySymbols(ns); + +assert( + symbolKeys.length > 0, + 'at least as many Symbol keys as defined by the specification' +); +assert( + symbolKeys.indexOf(Symbol.toStringTag) > -1, + 'Symbol keys array includes Symbol.toStringTag' +); + +var allKeys = Reflect.ownKeys(ns); + +assert( + allKeys.length >= 11, + 'at least as many keys as defined by the module and the specification' +); +assert.sameValue(allKeys[0], 'a_local1'); +assert.sameValue(allKeys[1], 'b_renamed'); +assert.sameValue(allKeys[2], 'c_localUninit1'); +assert.sameValue(allKeys[3], 'd_renamedUninit'); +assert.sameValue(allKeys[4], 'default'); +assert.sameValue(allKeys[5], 'e_indirect'); +assert.sameValue(allKeys[6], 'f_indirectUninit'); +assert.sameValue(allKeys[7], 'g_star'); +assert.sameValue(allKeys[8], 'h_starRenamed'); +assert.sameValue(allKeys[9], 'i_starIndirect'); +assert( + allKeys.indexOf(Symbol.toStringTag) > 9, + 'keys array includes Symbol.toStringTag' +); + +export let c_localUninit1; +let localUninit2; +export { localUninit2 as d_renamedUninit }; +export { c_localUninit1 as f_indirectUninit } from './own-property-keys-binding-types.js'; +export default null; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-binding-types_FIXTURE.js b/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-binding-types_FIXTURE.js new file mode 100644 index 0000000000..5e9cd63759 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-binding-types_FIXTURE.js @@ -0,0 +1,7 @@ +// |reftest| skip -- not a test file +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var g_star; +export { g_star as h_starRenamed }; +export { a_local1 as i_starIndirect } from './own-property-keys-binding-types.js'; diff --git a/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-sort.js b/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-sort.js new file mode 100644 index 0000000000..b837cfb8b2 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-sort.js @@ -0,0 +1,83 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-ownpropertykeys +description: > + The [[OwnPropertyKeys]] internal method reflects the sorted order +info: | + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. +flags: [module] +features: [Reflect, Symbol.toStringTag] +---*/ + +var x; +export { x as π }; // u03c0 +export { x as az }; +export { x as __ }; +export { x as za }; +export { x as Z }; +export { x as \u03bc }; +export { x as z }; +export { x as zz }; +export { x as a }; +export { x as A }; +export { x as aa }; +export { x as λ }; // u03bb +export { x as _ }; +export { x as $$ }; +export { x as $ }; +export default null; + +import * as ns from './own-property-keys-sort.js'; + +var stringKeys = Object.getOwnPropertyNames(ns); + +assert.sameValue(stringKeys.length, 16); +assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"'); +assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"'); +assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"'); +assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"'); +assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"'); +assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"'); +assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"'); +assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"'); +assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"'); +assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"'); +assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"'); +assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"'); +assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"'); +assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"'); +assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"'); +assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"'); + +var allKeys = Reflect.ownKeys(ns); +assert( + allKeys.length >= 17, + 'at least as many keys as defined by the module and the specification' +); +assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"'); +assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"'); +assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"'); +assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"'); +assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"'); +assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"'); +assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"'); +assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"'); +assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"'); +assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"'); +assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"'); +assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"'); +assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"'); +assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"'); +assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"'); +assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"'); +assert( + allKeys.indexOf(Symbol.toStringTag) > 15, + 'keys array includes Symbol.toStringTag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/prevent-extensions.js b/js/src/tests/test262/language/module-code/namespace/internals/prevent-extensions.js new file mode 100644 index 0000000000..c95ba59e96 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/prevent-extensions.js @@ -0,0 +1,18 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-preventextensions +description: The [[PreventExtensions]] internal method returns `true` +flags: [module] +features: [Reflect] +---*/ + +import * as ns from './prevent-extensions.js'; + +// This invocation should not throw an exception +Object.preventExtensions(ns); + +assert.sameValue(Reflect.preventExtensions(ns), true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/set-prototype-of-null.js b/js/src/tests/test262/language/module-code/namespace/internals/set-prototype-of-null.js new file mode 100644 index 0000000000..518cef68cc --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/set-prototype-of-null.js @@ -0,0 +1,17 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-setprototypeof-v +description: > + The [[SetPrototypeOf]] internal method returns `true` if + passed `null` +flags: [module] +---*/ + +import * as ns from './set-prototype-of-null.js'; + +assert.sameValue(typeof Object.setPrototypeOf, 'function'); +assert.sameValue(ns, Object.setPrototypeOf(ns, null)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/set-prototype-of.js b/js/src/tests/test262/language/module-code/namespace/internals/set-prototype-of.js new file mode 100644 index 0000000000..d24340dcec --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/set-prototype-of.js @@ -0,0 +1,19 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-setprototypeof +description: The [[SetPrototypeOf]] internal method returns `false` +flags: [module] +---*/ + +import * as ns from './set-prototype-of.js'; +var newProto = {}; + +assert.sameValue(typeof Object.setPrototypeOf, 'function'); + +assert.throws(TypeError, function() { + Object.setPrototypeOf(ns, newProto); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/set.js b/js/src/tests/test262/language/module-code/namespace/internals/set.js new file mode 100644 index 0000000000..192f0def9d --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/set.js @@ -0,0 +1,59 @@ +// |reftest| module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-set-p-v-receiver +description: The [[Set]] internal method consistently returns `false` +info: | + 1. Return false. +flags: [module] +features: [Reflect, Symbol, Symbol.toStringTag] +---*/ + +import * as ns from './set.js'; +export var local1 = null; +var local2 = null; +export { local2 as renamed }; +export { local1 as indirect } from './set.js'; +var sym = Symbol('test262'); + +assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); +assert.throws(TypeError, function() { + ns.local1 = null; +}, 'AssignmentExpression: local1'); + +assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); +assert.throws(TypeError, function() { + ns.local2 = null; +}, 'AssignmentExpression: local2'); + +assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); +assert.throws(TypeError, function() { + ns.renamed = null; +}, 'AssignmentExpression: renamed'); + +assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); +assert.throws(TypeError, function() { + ns.indirect = null; +}, 'AssignmentExpression: indirect'); + +assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); +assert.throws(TypeError, function() { + ns.default = null; +}, 'AssignmentExpression: default'); + +assert.sameValue( + Reflect.set(ns, Symbol.toStringTag), + false, + 'Reflect.set: Symbol.toStringTag' +); +assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = null; +}, 'AssignmentExpression: Symbol.toStringTag'); + +assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); +assert.throws(TypeError, function() { + ns[sym] = null; +}, 'AssignmentExpression: sym'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/module-code/namespace/internals/shell.js b/js/src/tests/test262/language/module-code/namespace/internals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/module-code/namespace/internals/shell.js |