diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions')
13 files changed, 698 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/browser.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/browser.js diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/default-option-values.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/default-option-values.js new file mode 100644 index 0000000000..96475e2ded --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/default-option-values.js @@ -0,0 +1,82 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Default values for each option +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 6, except the header row, in table order, do + a. Let p be the Property value of the current row. + b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). + 6. Return options. + + Table 6: Resolved Options of DisplayNames Instances + + [[Locale]]: "locale" + [[Style]]: "style" + [[Type]]: "type" + [[Fallback]]: "fallback" + + Intl.DisplayNames ( locales , options ) + + ... + 7. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). + ... + 9. Let r be ResolveLocale(%DisplayNames%.[[AvailableLocales]], requestedLocales, opt, + %DisplayNames%.[[RelevantExtensionKeys]]). + 10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long"). + ... + 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined). + 13. If type is undefined, throw a TypeError exception. + ... + 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code"). + ... + 17. Set displayNames.[[Locale]] to the value of r.[[Locale]]. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + ... +locale: [en-US] +features: [Intl.DisplayNames] +includes: [propertyHelper.js] +---*/ + +var dn = new Intl.DisplayNames('en-US', {type: 'language'}); + +var options = dn.resolvedOptions(); + +verifyProperty(options, 'style', { + value: 'long', + writable: true, + enumerable: true, + configurable: true +}); + +verifyProperty(options, 'type', { + value: 'language', + writable: true, + enumerable: true, + configurable: true +}); + +verifyProperty(options, 'fallback', { + value: 'code', + writable: true, + enumerable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/length.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/length.js new file mode 100644 index 0000000000..402df82db0 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Intl.DisplayNames.prototype.resolvedOptions.length is 0. +info: | + 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] +features: [Intl.DisplayNames] +---*/ + +verifyProperty(Intl.DisplayNames.prototype.resolvedOptions, "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/name.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/name.js new file mode 100644 index 0000000000..91f54d44cc --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Intl.DisplayNames.prototype.resolvedOptions.name is "resolvedOptions". +info: | + 17 ECMAScript Standard Built-in Objects: + + 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, 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.DisplayNames] +---*/ + +verifyProperty(Intl.DisplayNames.prototype.resolvedOptions, "name", { + value: "resolvedOptions", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-fallback.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-fallback.js new file mode 100644 index 0000000000..2fe0d03843 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-fallback.js @@ -0,0 +1,87 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Values for the fallback option +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 6, except the header row, in table order, do + a. Let p be the Property value of the current row. + b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). + 6. Return options. + + Table 6: Resolved Options of DisplayNames Instances + + [[Locale]]: "locale" + [[Style]]: "style" + [[Type]]: "type" + [[Fallback]]: "fallback" + [[LanguageDisplay]]: "languageDisplay" + + Intl.DisplayNames ( locales , options ) + + ... + 10. Let r be ResolveLocale(%DisplayNames%.[[AvailableLocales]], requestedLocales, opt, + %DisplayNames%.[[RelevantExtensionKeys]]). + 11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long"). + ... + 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined). + 13. If type is undefined, throw a TypeError exception. + ... + 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code"). + ... + 17. Set displayNames.[[Locale]] to the value of r.[[Locale]]. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + ... +locale: [en-US] +features: [Intl.DisplayNames] +includes: [propertyHelper.js] +---*/ + +const fallbacks = ['code', 'none']; +const types = ['language', 'region', 'script', 'currency']; + +types.forEach(type => { + fallbacks.forEach(fallback => { + const dn = new Intl.DisplayNames('en-US', { fallback, type }); + const options = dn.resolvedOptions(); + + verifyProperty(options, 'fallback', { + value: fallback, + writable: true, + enumerable: true, + configurable: true + }); + + verifyProperty(options, 'type', { + value: type, + writable: true, + enumerable: true, + configurable: true + }); + + verifyProperty(options, 'style', { + value: 'long', + writable: true, + enumerable: true, + configurable: true + }); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-languagedisplay.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-languagedisplay.js new file mode 100644 index 0000000000..3b3317a9d6 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-languagedisplay.js @@ -0,0 +1,70 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: Values for the languageDisplay option +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 6, except the header row, in table order, do + a. Let p be the Property value of the current row. + b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). + 6. Return options. + + Table 6: Resolved Options of DisplayNames Instances + + [[Locale]]: "locale" + [[Style]]: "style" + [[Type]]: "type" + [[Fallback]]: "fallback" + [[LanguageDisplay]]: "languageDisplay" + + Intl.DisplayNames ( locales , options ) + + ... + 24. Let languageDisplay be ? GetOption(options, "languageDisplay", "string", + « "dialect", "standard" », "dialect"). + 25. If type is "language", then + a. Set displayNames.[[LanguageDisplay]] to languageDisplay. + b. Let typeFields be typeFields.[[<languageDisplay>]]. + c. Assert: typeFields is a Record (see 1.4.3). + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + ... +locale: [en-US] +features: [Intl.DisplayNames-v2] +includes: [propertyHelper.js] +---*/ + +var dn; + +dn = new Intl.DisplayNames('en-US', { type: 'language', languageDisplay: 'dialect' }); + +verifyProperty(dn.resolvedOptions(), 'languageDisplay', { + value: 'dialect', + writable: true, + enumerable: true, + configurable: true +}); + +dn = new Intl.DisplayNames('en-US', { type: 'language', languageDisplay: 'standard' }); + +verifyProperty(dn.resolvedOptions(), 'languageDisplay', { + value: 'standard', + writable: true, + enumerable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-style.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-style.js new file mode 100644 index 0000000000..12961ca43e --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-style.js @@ -0,0 +1,89 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Values for the style option +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 6, except the header row, in table order, do + a. Let p be the Property value of the current row. + b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). + 6. Return options. + + Table 6: Resolved Options of DisplayNames Instances + + [[Locale]]: "locale" + [[Style]]: "style" + [[Type]]: "type" + [[Fallback]]: "fallback" + [[LanguageDisplay]]: "languageDisplay" + + Intl.DisplayNames ( locales , options ) + + ... + 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). + ... + 10. Let r be ResolveLocale(%DisplayNames%.[[AvailableLocales]], requestedLocales, opt, + %DisplayNames%.[[RelevantExtensionKeys]]). + 10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long"). + ... + 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined). + 13. If type is undefined, throw a TypeError exception. + ... + 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code"). + ... + 17. Set displayNames.[[Locale]] to the value of r.[[Locale]]. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + ... +locale: [en-US] +features: [Intl.DisplayNames] +includes: [propertyHelper.js] +---*/ + +const styles = ['narrow', 'short', 'long']; +const types = ['language', 'region', 'script', 'currency']; + +types.forEach(type => { + styles.forEach(style => { + const dn = new Intl.DisplayNames('en-US', { style, type }); + const options = dn.resolvedOptions(); + + verifyProperty(options, 'style', { + value: style, + writable: true, + enumerable: true, + configurable: true + }); + + verifyProperty(options, 'type', { + value: type, + writable: true, + enumerable: true, + configurable: true + }); + + verifyProperty(options, 'fallback', { + value: 'code', + writable: true, + enumerable: true, + configurable: true + }); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-type.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-type.js new file mode 100644 index 0000000000..5bb0254f0e --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/option-type.js @@ -0,0 +1,86 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Values for the type option +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 6, except the header row, in table order, do + a. Let p be the Property value of the current row. + b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). + 6. Return options. + + Table 6: Resolved Options of DisplayNames Instances + + [[Locale]]: "locale" + [[Style]]: "style" + [[Type]]: "type" + [[Fallback]]: "fallback" + [[LanguageDisplay]]: "languageDisplay" + + Intl.DisplayNames ([ locales [ , options ]]) + + ... + 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). + ... + 10. Let r be ResolveLocale(%DisplayNames%.[[AvailableLocales]], requestedLocales, opt, + %DisplayNames%.[[RelevantExtensionKeys]]). + 11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long"). + ... + 13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency"», + "language"). + ... + 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code"). + ... + 17. Set displayNames.[[Locale]] to the value of r.[[Locale]]. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + ... +locale: [en-US] +features: [Intl.DisplayNames] +includes: [propertyHelper.js] +---*/ + +var types = ['language', 'region', 'script', 'currency']; + +types.forEach(type => { + var dn = new Intl.DisplayNames('en-US', { type }); + var options = dn.resolvedOptions(); + + verifyProperty(options, 'type', { + value: type, + writable: true, + enumerable: true, + configurable: true + }); + + verifyProperty(options, 'fallback', { + value: 'code', + writable: true, + enumerable: true, + configurable: true + }); + + verifyProperty(options, 'style', { + value: 'long', + writable: true, + enumerable: true, + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/prop-desc.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/prop-desc.js new file mode 100644 index 0000000000..1766f5a5ce --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/prop-desc.js @@ -0,0 +1,30 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Property descriptor of Intl.DisplayNames.prototype.resolvedOptions +info: | + 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] +features: [Intl.DisplayNames] +---*/ + +assert.sameValue( + typeof Intl.DisplayNames.prototype.resolvedOptions, + "function", + "`typeof Intl.DisplayNames.prototype.resolvedOptions` is `'function'`" +); + +verifyProperty(Intl.DisplayNames.prototype, "resolvedOptions", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/return-object.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/return-object.js new file mode 100644 index 0000000000..9f5d2f8e3d --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/return-object.js @@ -0,0 +1,100 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Returns a new ordinary object on each call, with data properties containing values from internals +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 6, except the header row, in table order, do + a. Let p be the Property value of the current row. + b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row. + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). + 6. Return options. + + Table 6: Resolved Options of DisplayNames Instances + + [[Locale]]: "locale" + [[Style]]: "style" + [[Type]]: "type" + [[Fallback]]: "fallback" + [[LanguageDisplay]]: "languageDisplay" + + Intl.DisplayNames ( locales , options ) + + ... + 7. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). + ... + 9. Let r be ResolveLocale(%DisplayNames%.[[AvailableLocales]], requestedLocales, opt, + %DisplayNames%.[[RelevantExtensionKeys]]). + 10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long"). + ... + 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined). + 13. If type is undefined, throw a TypeError exception. + ... + 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code"). + ... + 17. Set displayNames.[[Locale]] to the value of r.[[Locale]]. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + ... +locale: [en-US] +features: [Intl.DisplayNames-v2, Reflect] +includes: [propertyHelper.js, compareArray.js] +---*/ + +const dn = new Intl.DisplayNames('en-US', {type: 'language'}); + +const options = dn.resolvedOptions(); +const other = dn.resolvedOptions(); + +assert.notSameValue(options, other, 'each call returns a new object'); + +assert.sameValue(Object.getPrototypeOf(options), Object.prototype, 'ordinary object #1'); +assert.sameValue(Object.getPrototypeOf(other), Object.prototype, 'ordinary object #2'); + +assert.compareArray( + Reflect.ownKeys(options), + ['locale', 'style', 'type', 'fallback', 'languageDisplay'], + 'all the data properties set to this object, in order of creation' +); + +verifyProperty(options, 'locale', { + value: 'en-US', + writable: true, + enumerable: true, + configurable: true +}); + +const explicit = new Intl.DisplayNames( + 'en', { localeMatcher: 'lookup', type: 'language' }).resolvedOptions(); + +assert.sameValue( + explicit.hasOwnProperty('localeMatcher'), + false, + 'the localeMatcher option is not set, option was explicitly set' +); + +const extra = new Intl.DisplayNames( + 'en', { chaos: 'yes', random: 'sure', '0': 42, type: 'language' }).resolvedOptions(); + +assert.compareArray( + Reflect.ownKeys(extra), + ['locale', 'style', 'type', 'fallback', 'languageDisplay'], + 'extra properties are not reflected in the resolvedOptions' +); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/shell.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/shell.js diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/this-not-object-throws.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/this-not-object-throws.js new file mode 100644 index 0000000000..42cac5976e --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/this-not-object-throws.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Throws a TypeError if this is not Object. +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + ... +features: [Intl.DisplayNames, Symbol] +---*/ + +var resolvedOptions = Intl.DisplayNames.prototype.resolvedOptions; + +assert.throws(TypeError, function() { + resolvedOptions(); +}, 'direct call'); + +assert.throws(TypeError, function() { + resolvedOptions.call('en'); +}, 'string'); + +assert.throws(TypeError, function() { + resolvedOptions.call(1); +}, 'number'); + +assert.throws(TypeError, function() { + resolvedOptions.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + resolvedOptions.call(true); +}, 'true'); + +assert.throws(TypeError, function() { + resolvedOptions.call(false); +}, 'false'); + +var symbol = Symbol(); +assert.throws(TypeError, function() { + resolvedOptions.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/this-object-lacks-internal-throws.js b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/this-object-lacks-internal-throws.js new file mode 100644 index 0000000000..9ad4c1517b --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/resolvedOptions/this-object-lacks-internal-throws.js @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames.prototype.resolvedOptions +description: > + Throws a TypeError if this does not have an [[InitializedDisplayNames]] internal slot. +info: | + Intl.DisplayNames.prototype.resolvedOptions () + + 1. Let pr be the this value. + 2. If Type(pr) is not Object or pr does not have an [[InitializedDisplayNames]] internal slot, + throw a TypeError exception. + ... +features: [Intl.DisplayNames] +---*/ + +var resolvedOptions = Intl.DisplayNames.prototype.resolvedOptions; + +assert.throws(TypeError, function() { + Intl.DisplayNames.prototype.resolvedOptions(); +}, 'Intl.DisplayNames.prototype does not have the internal slot'); + +assert.throws(TypeError, function() { + resolvedOptions.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + resolvedOptions.call(Intl.DisplayNames); +}, 'Intl.DisplayNames does not have the internal slot'); + +assert.throws(TypeError, function() { + resolvedOptions.call(Intl); +}, 'Intl does not have the internal slot'); + +// Not DisplayNames!!! +var dtf = new Intl.DateTimeFormat(); + +assert.throws(TypeError, function() { + resolvedOptions.call(dtf); +}, 'resolvedOptions cannot be used with instances from different Intl ctors'); + +reportCompare(0, 0); |