diff options
Diffstat (limited to 'js/src/tests/test262/intl402/Locale/prototype/getWeekInfo')
9 files changed, 255 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/branding.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/branding.js new file mode 100644 index 0000000000..de77d1d1a7 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/branding.js @@ -0,0 +1,30 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2023 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Locale.prototype.getWeekInfo +description: Verifies the branding check for the "getWeekInfo" function of the Locale prototype object. +info: | + Intl.Locale.prototype.getWeekInfo () + + 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). + +features: [Intl.Locale,Intl.Locale-info] +---*/ + +const getWeekInfo = Intl.Locale.prototype.getWeekInfo; + +assert.sameValue(typeof getWeekInfo, "function"); + +assert.throws(TypeError, () => getWeekInfo.call(undefined), "undefined"); +assert.throws(TypeError, () => getWeekInfo.call(null), "null"); +assert.throws(TypeError, () => getWeekInfo.call(true), "true"); +assert.throws(TypeError, () => getWeekInfo.call(""), "empty string"); +assert.throws(TypeError, () => getWeekInfo.call(Symbol()), "symbol"); +assert.throws(TypeError, () => getWeekInfo.call(1), "1"); +assert.throws(TypeError, () => getWeekInfo.call({}), "plain object"); +assert.throws(TypeError, () => getWeekInfo.call(Intl.Locale), "Intl.Locale"); +assert.throws(TypeError, () => getWeekInfo.call(Intl.Locale.prototype), "Intl.Locale.prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/browser.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/browser.js diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/firstDay-by-id.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/firstDay-by-id.js new file mode 100644 index 0000000000..9eedea5b8c --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/firstDay-by-id.js @@ -0,0 +1,34 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2023 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale.prototype.getWeekInfo +description: > + Checks that the return value of Intl.Locale.prototype.getWeekInfo is an Object + with the correct keys and properties. +info: | + get Intl.Locale.prototype.getWeekInfo + ... + 6. Perform ! CreateDataPropertyOrThrow(info, "firstDay", wi.[[FirstDay]]). +features: [Reflect,Intl.Locale,Intl.Locale-info] +---*/ + +const validFirstDayOfWeekIds = [ + ["en-u-fw-mon", 1], + ["en-u-fw-tue", 2], + ["en-u-fw-wed", 3], + ["en-u-fw-thu", 4], + ["en-u-fw-fri", 5], + ["en-u-fw-sat", 6], + ["en-u-fw-sun", 7], +]; +for (const [id, expected] of validFirstDayOfWeekIds) { + assert.sameValue( + new Intl.Locale(id).getWeekInfo().firstDay, + expected, + `new Intl.Locale(${id}).getWeekInfo().firstDay returns "${expected}"` + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/firstDay-by-option.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/firstDay-by-option.js new file mode 100644 index 0000000000..9b0619c810 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/firstDay-by-option.js @@ -0,0 +1,55 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2023 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale.prototype.getWeekInfo +description: > + Checks that the return value of Intl.Locale.prototype.getWeekInfo is an Object + with the correct keys and properties. +info: | + get Intl.Locale.prototype.getWeekInfo + ... + 6. Perform ! CreateDataPropertyOrThrow(info, "firstDay", wi.[[FirstDay]]). +features: [Reflect,Intl.Locale,Intl.Locale-info] +---*/ + +const validFirstDayOfWeekOptions = [ + ["mon", 1], + ["tue", 2], + ["wed", 3], + ["thu", 4], + ["fri", 5], + ["sat", 6], + ["sun", 7], + ["1", 1], + ["2", 2], + ["3", 3], + ["4", 4], + ["5", 5], + ["6", 6], + ["7", 7], + ["0", 7], + [1, 1], + [2, 2], + [3, 3], + [4, 4], + [5, 5], + [6, 6], + [7, 7], + [0, 7], +]; +for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) { + assert.sameValue( + new Intl.Locale('en', { firstDayOfWeek }).getWeekInfo().firstDay, + expected, + `new Intl.Locale("en", { firstDayOfWeek: ${firstDayOfWeek} }).getWeekInfo().firstDay returns "${expected}"` + ); + assert.sameValue( + new Intl.Locale('en-u-fw-WED', { firstDayOfWeek }).getWeekInfo().firstDay, + expected, + `new Intl.Locale("en-u-fw-WED", { firstDayOfWeek: ${firstDayOfWeek} }).firstDayOfWeek returns "${expected}"` + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/name.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/name.js new file mode 100644 index 0000000000..b834ac2749 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/name.js @@ -0,0 +1,23 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2023 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Locale.prototype.getWeekInfo +description: Checks the "name" property of Intl.Locale.prototype.getWeekInfo(). +info: | + 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 2019 Language Specification, 10th edition, clause 17, or successor. + Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification. + Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Intl.Locale,Intl.Locale-info] +---*/ + +verifyProperty(Intl.Locale.prototype.getWeekInfo, "name", { + value: "getWeekInfo", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/output-object-keys.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/output-object-keys.js new file mode 100644 index 0000000000..0d3da38f07 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/output-object-keys.js @@ -0,0 +1,67 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2021 Igalia, S.L. All rights reserved. +// Copyright 2021 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale.prototype.getWeekInfo +description: > + Checks that the return value of Intl.Locale.prototype.getWeekInfo is an Object + with the correct keys and properties. +info: | + get Intl.Locale.prototype.getWeekInfo + ... + 6. Perform ! CreateDataPropertyOrThrow(info, "firstDay", wi.[[FirstDay]]). + 7. Perform ! CreateDataPropertyOrThrow(info, "weekend", we). + 8. Perform ! CreateDataPropertyOrThrow(info, "minimalDays", wi.[[MinimalDays]]). + ... + CreateDataProperty ( O, P, V ) + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: true }. +features: [Reflect,Intl.Locale,Intl.Locale-info] +includes: [propertyHelper.js, compareArray.js] +---*/ + +const result = new Intl.Locale('en').getWeekInfo(); +function isIntegerBetweenOneAndSeven(value) { + return value === 1 || value === 2 || value === 3 || value === 4 || value === 5 || value === 6 || value === 7; +} + +assert.compareArray(Reflect.ownKeys(result), ['firstDay', 'weekend', 'minimalDays']); + +verifyProperty(result, 'firstDay', { + writable: true, + enumerable: true, + configurable: true +}); +assert( + isIntegerBetweenOneAndSeven(new Intl.Locale('en').getWeekInfo().firstDay), + '`firstDay` must be an integer between one and seven (inclusive)' +); + +verifyProperty(result, 'weekend', { + writable: true, + enumerable: true, + configurable: true +}); +assert( + new Intl.Locale('en').getWeekInfo().weekend.every(isIntegerBetweenOneAndSeven), + '`weekend` must include integers between one and seven (inclusive)' +); + +let original = new Intl.Locale('en').getWeekInfo().weekend; +let sorted = original.slice().sort(); +assert.compareArray(original, sorted); + +verifyProperty(result, 'minimalDays', { + writable: true, + enumerable: true, + configurable: true +}); +assert( + isIntegerBetweenOneAndSeven(new Intl.Locale('en').getWeekInfo().minimalDays), + '`minimalDays` must be an integer between one and seven (inclusive)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/output-object.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/output-object.js new file mode 100644 index 0000000000..b799a3db78 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/output-object.js @@ -0,0 +1,18 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale.prototype.getWeekInfo +description: > + Checks that the return value of Intl.Locale.prototype.getWeekInfo is an Object. +info: | + get Intl.Locale.prototype.getWeekInfo + ... + 5. Let info be ! ObjectCreate(%Object.prototype%). +features: [Intl.Locale,Intl.Locale-info] +---*/ + +assert.sameValue(Object.getPrototypeOf(new Intl.Locale('en').getWeekInfo()), Object.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/prop-desc.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/prop-desc.js new file mode 100644 index 0000000000..2ed856a03d --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/prop-desc.js @@ -0,0 +1,28 @@ +// |reftest| skip -- Intl.Locale-info is not supported +// Copyright 2023 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Locale.prototype.getWeekInfo +description: Checks the "getWeekInfo" property of the Locale prototype object. +info: | + Intl.Locale.prototype.getWeekInfo () + 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 2019 Language Specification, 10th edition, clause 17, or successor. + 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] +features: [Intl.Locale,Intl.Locale-info] +---*/ + +assert.sameValue( + typeof Intl.Locale.prototype.getWeekInfo, + "function", + "typeof Intl.Locale.prototype.getWeekInfo is function" +); + +verifyProperty(Intl.Locale.prototype, "getWeekInfo", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/shell.js b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/getWeekInfo/shell.js |