diff options
Diffstat (limited to 'js/src/tests/test262/intl402/PluralRules')
52 files changed, 1032 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/PluralRules/browser.js b/js/src/tests/test262/intl402/PluralRules/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/builtin.js b/js/src/tests/test262/intl402/PluralRules/builtin.js new file mode 100644 index 0000000000..7979c93243 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/builtin.js @@ -0,0 +1,21 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules +description: > + Tests that Intl.PluralRules meets the requirements for + built-in objects defined by the introduction of chapter 17 of the + ECMAScript Language Specification. +author: Zibi Braniecki +---*/ + +assert.sameValue(Object.prototype.toString.call(Intl.PluralRules), "[object Function]", + "The [[Class]] internal property of a built-in function must be " + + "\"Function\"."); + +assert(Object.isExtensible(Intl.PluralRules), "Built-in objects must be extensible."); + +assert.sameValue(Object.getPrototypeOf(Intl.PluralRules), Function.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/can-be-subclassed.js b/js/src/tests/test262/intl402/PluralRules/can-be-subclassed.js new file mode 100644 index 0000000000..e09c8b5f51 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/can-be-subclassed.js @@ -0,0 +1,30 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-intl-pluralrules-constructor +description: Tests that Intl.PluralRules can be subclassed. +author: Zibi Braniecki +includes: [compareArray.js] +---*/ + +// get a plural-rules and have it format an array of dates for comparison with the subclass +var locales = ["tlh", "id", "en"]; +var a = [1, 5, 12]; + +var referencePluralRules = new Intl.PluralRules(locales); +var referenceSelected = a.map(referencePluralRules.select.bind(referencePluralRules)); + +class MyPluralRules extends Intl.PluralRules { + constructor(locales, options) { + super(locales, options); + // could initialize MyPluralRules properties + } + // could add methods to MyPluralRules.prototype +} + +var pr = new MyPluralRules(locales); +var actual = a.map(pr.select.bind(pr)); +assert.compareArray(actual, referenceSelected); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/constructor-options-throwing-getters.js b/js/src/tests/test262/intl402/PluralRules/constructor-options-throwing-getters.js new file mode 100644 index 0000000000..3099b1d1a2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/constructor-options-throwing-getters.js @@ -0,0 +1,31 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializepluralrules +description: Checks the propagation of exceptions from the options for the NumberFormat constructor. +---*/ + +function CustomError() {} + +const options = [ + "localeMatcher", + "type", + "minimumIntegerDigits", + "minimumFractionDigits", + "maximumFractionDigits", + "minimumSignificantDigits", + "maximumSignificantDigits", +]; + +for (const option of options) { + assert.throws(CustomError, () => { + new Intl.PluralRules("en", { + get [option]() { + throw new CustomError(); + } + }); + }, `Exception from ${option} getter should be propagated`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/default-options-object-prototype.js b/js/src/tests/test262/intl402/PluralRules/default-options-object-prototype.js new file mode 100644 index 0000000000..fc837a2e2c --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/default-options-object-prototype.js @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Igalia, S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializepluralrules +description: > + Monkey-patching Object.prototype does not change the default + options for PluralRules as a null prototype is used. +info: | + InitializePluralRules ( collator, locales, options ) + + 1. If _options_ is *undefined*, then + 1. Let _options_ be ObjectCreate(*null*). +---*/ + +Object.prototype.type = "ordinal"; +let pluralRules = new Intl.PluralRules("en"); +assert.sameValue(pluralRules.resolvedOptions().type, "cardinal"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/internals.js b/js/src/tests/test262/intl402/PluralRules/internals.js new file mode 100644 index 0000000000..db0b3a19b9 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/internals.js @@ -0,0 +1,19 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-intl-pluralrules-constructor +description: > + Tests that objects constructed by Intl.PluralRules have the specified + internal properties. +author: Zibi Braniecki +---*/ + +var obj = new Intl.PluralRules(); + +var actualPrototype = Object.getPrototypeOf(obj); +assert.sameValue(actualPrototype, Intl.PluralRules.prototype, "Prototype of object constructed by Intl.PluralRules isn't Intl.PluralRules.prototype; got " + actualPrototype); + +assert(Object.isExtensible(obj), "Object constructed by Intl.PluralRules must be extensible."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/length.js b/js/src/tests/test262/intl402/PluralRules/length.js new file mode 100644 index 0000000000..cc2ea11067 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/length.js @@ -0,0 +1,18 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules +description: Intl.PluralRules.length. +author: Zibi Braniecki +includes: [propertyHelper.js] +---*/ + +verifyProperty(Intl.PluralRules, 'length', { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/name.js b/js/src/tests/test262/intl402/PluralRules/name.js new file mode 100644 index 0000000000..fdcfd0ae70 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/name.js @@ -0,0 +1,18 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules +description: Intl.PluralRules.name is "PluralRules" +author: Zibi Braniecki +includes: [propertyHelper.js] +---*/ + +verifyProperty(Intl.PluralRules, 'name', { + value: 'PluralRules', + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prop-desc.js b/js/src/tests/test262/intl402/PluralRules/prop-desc.js new file mode 100644 index 0000000000..d21a3fec88 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prop-desc.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules +description: > + "PluralRules" property of Intl. +info: | + Intl.PluralRules (...) + + 7 Requirements for Standard Built-in ECMAScript Objects + + Unless specified otherwise in this document, the objects, functions, and constructors + described in this standard are subject to the generic requirements and restrictions + specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language + Specification, 9th edition, clause 17, or successor. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 has the + attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. + +includes: [propertyHelper.js] +---*/ + +verifyProperty(Intl, 'PluralRules', { + writable: true, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/proto-from-ctor-realm.js b/js/src/tests/test262/intl402/PluralRules/proto-from-ctor-realm.js new file mode 100644 index 0000000000..c5834ea464 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/proto-from-ctor-realm.js @@ -0,0 +1,59 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + Intl.PluralRules ( [ locales [ , options ] ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let pluralRules be ? OrdinaryCreateFromConstructor(newTarget, "%PluralRulesPrototype%", « ... »). + 3. Return ? InitializePluralRules(pluralRules, locales, options). + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var pr; + +newTarget.prototype = undefined; +pr = Reflect.construct(Intl.PluralRules, [], newTarget); +assert.sameValue(Object.getPrototypeOf(pr), other.Intl.PluralRules.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +pr = Reflect.construct(Intl.PluralRules, [], newTarget); +assert.sameValue(Object.getPrototypeOf(pr), other.Intl.PluralRules.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = false; +pr = Reflect.construct(Intl.PluralRules, [], newTarget); +assert.sameValue(Object.getPrototypeOf(pr), other.Intl.PluralRules.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +pr = Reflect.construct(Intl.PluralRules, [], newTarget); +assert.sameValue(Object.getPrototypeOf(pr), other.Intl.PluralRules.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +pr = Reflect.construct(Intl.PluralRules, [], newTarget); +assert.sameValue(Object.getPrototypeOf(pr), other.Intl.PluralRules.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 0; +pr = Reflect.construct(Intl.PluralRules, [], newTarget); +assert.sameValue(Object.getPrototypeOf(pr), other.Intl.PluralRules.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/bind.js b/js/src/tests/test262/intl402/PluralRules/prototype/bind.js new file mode 100644 index 0000000000..9b5142866c --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/bind.js @@ -0,0 +1,28 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-properties-of-intl-pluralrules-prototype-object +description: > + Tests that Intl.PluralRules.prototype functions throw a TypeError if + called on a non-object value or an object that hasn't been + initialized as a PluralRules. +author: Zibi Braniecki +---*/ + +var functions = { + select: Intl.PluralRules.prototype.select, + resolvedOptions: Intl.PluralRules.prototype.resolvedOptions +}; +var invalidTargets = [undefined, null, true, 0, "PluralRules", [], {}]; + +Object.getOwnPropertyNames(functions).forEach(function (functionName) { + var f = functions[functionName]; + invalidTargets.forEach(function (target) { + assert.throws(TypeError, function () { + f.call(target); + }, "Calling " + functionName + " on " + target + " was not rejected."); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/browser.js b/js/src/tests/test262/intl402/PluralRules/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/builtins.js b/js/src/tests/test262/intl402/PluralRules/prototype/builtins.js new file mode 100644 index 0000000000..22bc883a14 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/builtins.js @@ -0,0 +1,18 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-properties-of-intl-pluralrules-prototype-object +description: > + Tests that Intl.PluralRules.prototype meets the requirements for + built-in objects defined by the introduction of chapter 17 of the + ECMAScript Language Specification. +author: Zibi Braniecki +---*/ + +assert(Object.isExtensible(Intl.PluralRules.prototype), "Built-in objects must be extensible."); + +assert.sameValue(Object.getPrototypeOf(Intl.PluralRules.prototype), Object.prototype, + "Built-in prototype objects must have Object.prototype as their prototype."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/constructor/browser.js b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/constructor/main.js b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/main.js new file mode 100644 index 0000000000..8a3bb64e8c --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/main.js @@ -0,0 +1,14 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.prototype.constructor +description: > + Tests that Intl.PluralRules.prototype is an object that has been + initialized as an Intl.PluralRules. +author: Zibi Braniecki +---*/ + +assert.sameValue(Intl.PluralRules.prototype.constructor, Intl.PluralRules, "Intl.PluralRules.prototype.constructor is not the same as Intl.PluralRules"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/constructor/prop-desc.js b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/prop-desc.js new file mode 100644 index 0000000000..4e9757a6c2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/prop-desc.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype.constructor +description: > + "constructor" property of Intl.PluralRules.prototype. +info: | + Intl.PluralRules.prototype.constructor + + 7 Requirements for Standard Built-in ECMAScript Objects + + Unless specified otherwise in this document, the objects, functions, and constructors + described in this standard are subject to the generic requirements and restrictions + specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language + Specification, 9th edition, clause 17, or successor. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 has the + attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Intl.PluralRules.prototype, "constructor"); +verifyWritable(Intl.PluralRules.prototype, "constructor"); +verifyConfigurable(Intl.PluralRules.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/constructor/shell.js b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/constructor/shell.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/properties.js b/js/src/tests/test262/intl402/PluralRules/prototype/properties.js new file mode 100644 index 0000000000..d30b187e6c --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/properties.js @@ -0,0 +1,17 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-properties-of-intl-pluralrules-prototype-object +description: Tests that Intl.PluralRules.prototype has the required attributes. +author: Zibi Braniecki +includes: [propertyHelper.js] +---*/ + +verifyProperty(Intl.PluralRules, "prototype", { + writable: false, + enumerable: false, + configurable: false, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/prototype.js b/js/src/tests/test262/intl402/PluralRules/prototype/prototype.js new file mode 100644 index 0000000000..6329c09f5f --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/prototype.js @@ -0,0 +1,18 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-properties-of-intl-pluralrules-prototype-object +description: > + Tests that Intl.PluralRules.prototype is not an object that has been + initialized as an Intl.PluralRules. +author: Zibi Braniecki +---*/ + +// test by calling a function that fails if "this" is not an object +// initialized as an Intl.PluralRules +assert.throws(TypeError, function() { + Intl.PluralRules.prototype.select(0); +}, "Intl.PluralRules.prototype is not an object that has been initialized as an Intl.PluralRules"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/browser.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/builtins.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/builtins.js new file mode 100644 index 0000000000..72e8ef9d1f --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/builtins.js @@ -0,0 +1,30 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.prototype.resolvedOptions +description: > + Tests that Intl.PluralRules.prototype.resolvedOptions meets the requirements for + built-in objects defined by the introduction of chapter 17 of the + ECMAScript Language Specification. +author: Zibi Braniecki +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype.resolvedOptions), "[object Function]", + "The [[Class]] internal property of a built-in function must be " + + "\"Function\"."); + +assert(Object.isExtensible(Intl.PluralRules.prototype.resolvedOptions), + "Built-in objects must be extensible."); + +assert.sameValue(Object.getPrototypeOf(Intl.PluralRules.prototype.resolvedOptions), Function.prototype); + +assert.sameValue(Intl.PluralRules.prototype.resolvedOptions.hasOwnProperty("prototype"), false, + "Built-in functions that aren't constructors must not have a prototype property."); + +assert.sameValue(isConstructor(Intl.PluralRules.prototype.resolvedOptions), false, + "Built-in functions don't implement [[Construct]] unless explicitly specified."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/length.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/length.js new file mode 100644 index 0000000000..6c40703981 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype.resolvedoptions +description: > + Intl.PluralRules.prototype.resolvedOptions.length is 0. +info: | + Intl.PluralRules.prototype.resolvedOptions () + + 17 ECMAScript Standard Built-in Objects: + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument count. + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Intl.PluralRules.prototype.resolvedOptions.length, 0); + +verifyNotEnumerable(Intl.PluralRules.prototype.resolvedOptions, "length"); +verifyNotWritable(Intl.PluralRules.prototype.resolvedOptions, "length"); +verifyConfigurable(Intl.PluralRules.prototype.resolvedOptions, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/name.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/name.js new file mode 100644 index 0000000000..92adab33f1 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/name.js @@ -0,0 +1,17 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.resolvedOptions.name +description: Intl.PluralRules.resolvedOptions.name is "resolvedOptions" +author: Zibi Braniecki +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Intl.PluralRules.prototype.resolvedOptions.name, "resolvedOptions"); + +verifyNotEnumerable(Intl.PluralRules.prototype.resolvedOptions, "name"); +verifyNotWritable(Intl.PluralRules.prototype.resolvedOptions, "name"); +verifyConfigurable(Intl.PluralRules.prototype.resolvedOptions, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/order.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/order.js new file mode 100644 index 0000000000..b4a87c0259 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/order.js @@ -0,0 +1,27 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.numberformat.prototype.resolvedoptions +description: Verifies the property order for the object returned by resolvedOptions(). +includes: [compareArray.js] +features: [Intl.NumberFormat-unified] +---*/ + +const options = new Intl.PluralRules([], { + "minimumSignificantDigits": 1, + "maximumSignificantDigits": 2, +}).resolvedOptions(); + +const expected = [ + "locale", + "type", + "minimumIntegerDigits", + "minimumSignificantDigits", + "maximumSignificantDigits", + "pluralCategories", +]; + +assert.compareArray(Object.getOwnPropertyNames(options), expected); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/pluralCategories.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/pluralCategories.js new file mode 100644 index 0000000000..fe4d6b5c1d --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/pluralCategories.js @@ -0,0 +1,31 @@ +// Copyright 2018 Igalia S.L. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.prototype.resolvedOptions +description: > + Tests that Intl.PluralRules.prototype.resolvedOptions creates a new array + for the pluralCategories property on every call. +includes: [propertyHelper.js, compareArray.js] +---*/ + +const allowedValues = ["zero", "one", "two", "few", "many", "other"]; + +const pluralrules = new Intl.PluralRules(); +const options1 = pluralrules.resolvedOptions(); +const options2 = pluralrules.resolvedOptions(); + +assert.notSameValue(options1.pluralCategories, options2.pluralCategories, "Should have different arrays"); +assert.compareArray(options1.pluralCategories, options2.pluralCategories, "Arrays should have same values"); + +for (const category of options1.pluralCategories) { + assert(allowedValues.includes(category), `Found ${category}, expected one of ${allowedValues}`); +} + +verifyProperty(options1, "pluralCategories", { + writable: true, + enumerable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/prop-desc.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/prop-desc.js new file mode 100644 index 0000000000..c35d943143 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/prop-desc.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype.resolvedoptions +description: > + "resolvedOptions" property of Intl.PluralRules.prototype. +info: | + Intl.PluralRules.prototype.resolvedOptions () + + 7 Requirements for Standard Built-in ECMAScript Objects + + Unless specified otherwise in this document, the objects, functions, and constructors + described in this standard are subject to the generic requirements and restrictions + specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language + Specification, 9th edition, clause 17, or successor. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 has the + attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Intl.PluralRules.prototype, "resolvedOptions"); +verifyWritable(Intl.PluralRules.prototype, "resolvedOptions"); +verifyConfigurable(Intl.PluralRules.prototype, "resolvedOptions"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/properties.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/properties.js new file mode 100644 index 0000000000..1db3cb1927 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/properties.js @@ -0,0 +1,38 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.prototype.resolvedOptions +description: > + Tests that the object returned by + Intl.PluralRules.prototype.resolvedOptions has the right + properties. +author: Zibi Braniecki +includes: [testIntl.js, propertyHelper.js] +---*/ + +var actual = new Intl.PluralRules().resolvedOptions(); + +var actual2 = new Intl.PluralRules().resolvedOptions(); +assert.notSameValue(actual2, actual, "resolvedOptions returned the same object twice."); + +// this assumes the default values where the specification provides them +assert(isCanonicalizedStructurallyValidLanguageTag(actual.locale), + "Invalid locale: " + actual.locale); +assert.sameValue(actual.type, "cardinal"); +assert.sameValue(actual.minimumIntegerDigits, 1); +assert.sameValue(actual.minimumFractionDigits, 0); +assert.sameValue(actual.maximumFractionDigits, 3); + +var dataPropertyDesc = { writable: true, enumerable: true, configurable: true }; +verifyProperty(actual, "locale", dataPropertyDesc); +verifyProperty(actual, "type", dataPropertyDesc); +verifyProperty(actual, "currency", undefined); +verifyProperty(actual, "currencyDisplay", undefined); +verifyProperty(actual, "minimumIntegerDigits", dataPropertyDesc); +verifyProperty(actual, "minimumFractionDigits", dataPropertyDesc); +verifyProperty(actual, "maximumFractionDigits", dataPropertyDesc); +verifyProperty(actual, "minimumSignificantDigits", undefined); +verifyProperty(actual, "maximumSignificantDigits", undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/shell.js b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/resolvedOptions/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/browser.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/length.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/length.js new file mode 100644 index 0000000000..baedab2dca --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype.select +description: > + Intl.PluralRules.prototype.select is 1. +info: | + Intl.PluralRules.prototype.select( value ) + + 17 ECMAScript Standard Built-in Objects: + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument count. + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Intl.PluralRules.prototype.select.length, 1); + +verifyNotEnumerable(Intl.PluralRules.prototype.select, "length"); +verifyNotWritable(Intl.PluralRules.prototype.select, "length"); +verifyConfigurable(Intl.PluralRules.prototype.select, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/name.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/name.js new file mode 100644 index 0000000000..5c2b10ab5e --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/name.js @@ -0,0 +1,19 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.prototype.select +description: Intl.PluralRules.prototype.select.name is "select" +author: Zibi Braniecki +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Intl.PluralRules.prototype.select.name, 'select', + 'The value of `Intl.PluralRules.prototype.select.name` is `"select"`' +); + +verifyNotEnumerable(Intl.PluralRules.prototype.select, 'name'); +verifyNotWritable(Intl.PluralRules.prototype.select, 'name'); +verifyConfigurable(Intl.PluralRules.prototype.select, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/non-finite.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/non-finite.js new file mode 100644 index 0000000000..14166d66ec --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/non-finite.js @@ -0,0 +1,24 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.prototype.select +description: Tests that select function returns "other" for non finite values. +info: | + 1.1.4. ResolvePlural (pluralRules, n) + (...) + 1.1.4_3. If isFinite(n) is false, then + 1.1.4_3.a. Return "other". +author: Zibi Braniecki + +---*/ + +var invalidValues = [NaN, Infinity, -Infinity]; + +var pr = new Intl.PluralRules(); + +invalidValues.forEach(function (value) { + assert.sameValue(pr.select(value), "other"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/prop-desc.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/prop-desc.js new file mode 100644 index 0000000000..13839624f1 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/prop-desc.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype.select +description: > + "select" property of Intl.PluralRules.prototype. +info: | + Intl.PluralRules.prototype.select( value ) + + 7 Requirements for Standard Built-in ECMAScript Objects + + Unless specified otherwise in this document, the objects, functions, and constructors + described in this standard are subject to the generic requirements and restrictions + specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language + Specification, 9th edition, clause 17, or successor. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 has the + attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Intl.PluralRules.prototype, "select"); +verifyWritable(Intl.PluralRules.prototype, "select"); +verifyConfigurable(Intl.PluralRules.prototype, "select"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/shell.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/shell.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/select/tainting.js b/js/src/tests/test262/intl402/PluralRules/prototype/select/tainting.js new file mode 100644 index 0000000000..19dc9eddc5 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/select/tainting.js @@ -0,0 +1,22 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-intl-pluralrules-abstracts +description: > + Tests that the behavior of a Record is not affected by + adversarial changes to Object.prototype. +info: | + 1.1.1. InitializePluralRules (pluralRules, locales, options) + (...) + 1.1.1_6. Let t be ? GetOption(options, "type", "string", « "cardinal", "ordinal" », "cardinal"). +author: Zibi Braniecki +includes: [testIntl.js] +---*/ + +taintProperties(["type"]); + +var pr = new Intl.PluralRules(); +var time = pr.select(9); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/shell.js b/js/src/tests/test262/intl402/PluralRules/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/shell.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/browser.js b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/shell.js b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/shell.js diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString-changed-tag.js b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString-changed-tag.js new file mode 100644 index 0000000000..20b48fcc35 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString-changed-tag.js @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype-tostringtag +description: > + Object.prototype.toString utilizes Intl.PluralRules.prototype[@@toStringTag]. +info: | + Object.prototype.toString ( ) + + [...] + 14. Else, let builtinTag be "Object". + 15. Let tag be ? Get(O, @@toStringTag). + 16. If Type(tag) is not String, set tag to builtinTag. + 17. Return the string-concatenation of "[object ", tag, and "]". + + Intl.PluralRules.prototype [ @@toStringTag ] + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +features: [Symbol.toStringTag] +---*/ + +Object.defineProperty(Intl.PluralRules.prototype, Symbol.toStringTag, { + value: "test262", +}); + +assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object test262]"); +assert.sameValue(Object.prototype.toString.call(new Intl.PluralRules()), "[object test262]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString-removed-tag.js b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString-removed-tag.js new file mode 100644 index 0000000000..02f835ff2f --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString-removed-tag.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype-tostringtag +description: > + Object.prototype.toString doesn't special-case neither Intl.PluralRules instances nor its prototype. +info: | + Object.prototype.toString ( ) + + [...] + 14. Else, let builtinTag be "Object". + 15. Let tag be ? Get(O, @@toStringTag). + 16. If Type(tag) is not String, set tag to builtinTag. + 17. Return the string-concatenation of "[object ", tag, and "]". +features: [Symbol.toStringTag] +---*/ + +delete Intl.PluralRules.prototype[Symbol.toStringTag]; + +assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object Object]"); +assert.sameValue(Object.prototype.toString.call(new Intl.PluralRules()), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString.js b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString.js new file mode 100644 index 0000000000..e5a30f15e4 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toString.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype-tostringtag +description: > + Object.prototype.toString utilizes Intl.PluralRules.prototype[@@toStringTag]. +info: | + Object.prototype.toString ( ) + + [...] + 14. Else, let builtinTag be "Object". + 15. Let tag be ? Get(O, @@toStringTag). + 16. If Type(tag) is not String, set tag to builtinTag. + 17. Return the string-concatenation of "[object ", tag, and "]". + + Intl.PluralRules.prototype [ @@toStringTag ] + + The initial value of the @@toStringTag property is the String value "Intl.PluralRules". +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.prototype), "[object Intl.PluralRules]"); +assert.sameValue(Object.prototype.toString.call(new Intl.PluralRules()), "[object Intl.PluralRules]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toStringTag.js b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toStringTag.js new file mode 100644 index 0000000000..cdac2facc9 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/prototype/toStringTag/toStringTag.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.prototype-tostringtag +description: > + Property descriptor of Intl.PluralRules.prototype[@@toStringTag]. +info: | + Intl.PluralRules.prototype [ @@toStringTag ] + + The initial value of the @@toStringTag property is the String value "Intl.PluralRules". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +features: [Symbol.toStringTag] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Intl.PluralRules.prototype, Symbol.toStringTag, { + value: "Intl.PluralRules", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/shell.js b/js/src/tests/test262/intl402/PluralRules/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/shell.js diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/arguments.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/arguments.js new file mode 100644 index 0000000000..bf6e487d6e --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/arguments.js @@ -0,0 +1,16 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.supportedLocalesOf +description: > + Tests that Intl.PluralRules.supportedLocalesOf doesn't access + arguments that it's not given. +author: Zibi Braniecki +includes: [testIntl.js] +---*/ + +taintDataProperty(Object.prototype, "1"); +new Intl.PluralRules("und"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/browser.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/browser.js diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/length.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/length.js new file mode 100644 index 0000000000..6192952f33 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.supportedlocalesof +description: > + Intl.PluralRules.supportedLocalesOf.length is 1. +info: | + Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ) + + 17 ECMAScript Standard Built-in Objects: + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument count. + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Intl.PluralRules.supportedLocalesOf.length, 1); + +verifyNotEnumerable(Intl.PluralRules.supportedLocalesOf, "length"); +verifyNotWritable(Intl.PluralRules.supportedLocalesOf, "length"); +verifyConfigurable(Intl.PluralRules.supportedLocalesOf, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/main.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/main.js new file mode 100644 index 0000000000..23afcb1099 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/main.js @@ -0,0 +1,25 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.supportedLocalesOf +description: > + Tests that Intl.PluralRules has a supportedLocalesOf property, and + it works as planned. +author: Zibi Braniecki +---*/ + +var defaultLocale = new Intl.PluralRules().resolvedOptions().locale; +var notSupported = 'zxx'; // "no linguistic content" +var requestedLocales = [defaultLocale, notSupported]; + +var supportedLocales; + +assert(Intl.PluralRules.hasOwnProperty('supportedLocalesOf'), "Intl.PluralRules doesn't have a supportedLocalesOf property."); + +supportedLocales = Intl.PluralRules.supportedLocalesOf(requestedLocales); +assert.sameValue(supportedLocales.length, 1, 'The length of supported locales list is not 1.'); + +assert.sameValue(supportedLocales[0], defaultLocale, 'The default locale is not returned in the supported list.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/name.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/name.js new file mode 100644 index 0000000000..a79e9180be --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/name.js @@ -0,0 +1,16 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.supportedLocalesOf +description: Tests that Intl.PluralRules.supportedLocalesOf.name is "supportedLocalesOf" +author: Zibi Braniecki +includes: [propertyHelper.js] +---*/ +assert.sameValue(Intl.PluralRules.supportedLocalesOf.name, "supportedLocalesOf"); + +verifyNotEnumerable(Intl.PluralRules.supportedLocalesOf, "name"); +verifyNotWritable(Intl.PluralRules.supportedLocalesOf, "name"); +verifyConfigurable(Intl.PluralRules.supportedLocalesOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/prop-desc.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/prop-desc.js new file mode 100644 index 0000000000..ac8a8d5ba3 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/prop-desc.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules.supportedlocalesof +description: > + "supportedLocalesOf" property of Intl.PluralRules. +info: | + Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ) + + 7 Requirements for Standard Built-in ECMAScript Objects + + Unless specified otherwise in this document, the objects, functions, and constructors + described in this standard are subject to the generic requirements and restrictions + specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language + Specification, 9th edition, clause 17, or successor. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 has the + attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Intl.PluralRules, "supportedLocalesOf"); +verifyWritable(Intl.PluralRules, "supportedLocalesOf"); +verifyConfigurable(Intl.PluralRules, "supportedLocalesOf"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/shell.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/supportedLocalesOf.js b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/supportedLocalesOf.js new file mode 100644 index 0000000000..1bff8cdb1c --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/supportedLocalesOf/supportedLocalesOf.js @@ -0,0 +1,30 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules.supportedLocalesOf +description: > + Tests that Intl.PluralRules.supportedLocalesOf meets the requirements for + built-in objects defined by the introduction of chapter 17 of the + ECMAScript Language Specification. +author: Zibi Braniecki +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(Object.prototype.toString.call(Intl.PluralRules.supportedLocalesOf), "[object Function]", + "The [[Class]] internal property of a built-in function must be " + + "\"Function\"."); + +assert(Object.isExtensible(Intl.PluralRules.supportedLocalesOf), + "Built-in objects must be extensible."); + +assert.sameValue(Object.getPrototypeOf(Intl.PluralRules.supportedLocalesOf), Function.prototype); + +assert.sameValue(Intl.PluralRules.supportedLocalesOf.hasOwnProperty("prototype"), false, + "Built-in functions that aren't constructors must not have a prototype property."); + +assert.sameValue(isConstructor(Intl.PluralRules.supportedLocalesOf), false, + "Built-in functions don't implement [[Construct]] unless explicitly specified."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/PluralRules/undefined-newtarget-throws.js b/js/src/tests/test262/intl402/PluralRules/undefined-newtarget-throws.js new file mode 100644 index 0000000000..77c82be1de --- /dev/null +++ b/js/src/tests/test262/intl402/PluralRules/undefined-newtarget-throws.js @@ -0,0 +1,27 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-Intl.PluralRules +description: Tests that PluralRules throws when called as a function +author: Zibi Braniecki +includes: [testIntl.js] +---*/ + +assert.throws(TypeError, function() { + Intl.PluralRules(); +}, "Intl.PluralRules throws when called as a function"); + +assert.throws(TypeError, function() { + Intl.PluralRules.call(undefined); +}, "Intl.PluralRules throws when called as a function with |undefined| as this-value"); + +testWithIntlConstructors(function (Constructor) { + var obj = new Constructor(); + + assert.throws(TypeError, function() { + Intl.PluralRules.call(obj) + }, "Intl.PluralRules throws when called as a function with an Intl-object as this-value"); +}); + +reportCompare(0, 0); |