diff options
Diffstat (limited to 'js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions')
9 files changed, 195 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js new file mode 100644 index 0000000000..756a9132d2 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/branding.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Verifies the branding check for the "resolvedOptions" function of the Segmenter prototype object. +info: | + Intl.Segmenter.prototype.resolvedOptions () + + 2. If Type(pr) is not Object or pr does not have an [[InitializedSegmenter]] internal slot, throw a TypeError exception. +features: [Intl.Segmenter] +---*/ + +const resolvedOptions = Intl.Segmenter.prototype.resolvedOptions; + +assert.sameValue(typeof resolvedOptions, "function"); + +assert.throws(TypeError, () => resolvedOptions.call(undefined), "undefined"); +assert.throws(TypeError, () => resolvedOptions.call(null), "null"); +assert.throws(TypeError, () => resolvedOptions.call(true), "true"); +assert.throws(TypeError, () => resolvedOptions.call(""), "empty string"); +assert.throws(TypeError, () => resolvedOptions.call(Symbol()), "symbol"); +assert.throws(TypeError, () => resolvedOptions.call(1), "1"); +assert.throws(TypeError, () => resolvedOptions.call({}), "plain object"); +assert.throws(TypeError, () => resolvedOptions.call(Intl.Segmenter), "Intl.Segmenter"); +assert.throws(TypeError, () => resolvedOptions.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/browser.js diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js new file mode 100644 index 0000000000..96c76ec704 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/caching.js @@ -0,0 +1,20 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Verifies that the return value of Intl.Segmenter.prototype.resolvedOptions() is not cached. +info: | + Intl.Segmenter.prototype.resolvedOptions () + + 3. Let options be ! ObjectCreate(%ObjectPrototype%). +features: [Intl.Segmenter] +---*/ + +const s = new Intl.Segmenter("en-us"); +const options1 = s.resolvedOptions(); +const options2 = s.resolvedOptions(); +assert.notSameValue(options1, options2, "Should create a new object each time."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.js new file mode 100644 index 0000000000..e43dea0c6d --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/length.js @@ -0,0 +1,24 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Checks the "length" property of Intl.Segmenter.prototype.resolvedOptions(). +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. + The Segmenter constructor is a standard built-in property of the Intl object. + 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.Segmenter] +---*/ + +verifyProperty(Intl.Segmenter.prototype.resolvedOptions, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js new file mode 100644 index 0000000000..041afb9d92 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/name.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Checks the "name" property of Intl.Segmenter.prototype.resolvedOptions(). +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.Segmenter] +---*/ + +verifyProperty(Intl.Segmenter.prototype.resolvedOptions, "name", { + value: "resolvedOptions", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js new file mode 100644 index 0000000000..aa254958c3 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/order.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Verifies the property order for the object returned by resolvedOptions(). +features: [Intl.Segmenter] +---*/ + +const options = new Intl.Segmenter([], { + "granularity": "word", +}).resolvedOptions(); + +const expected = [ + "locale", + "granularity", +]; + +const actual = Object.getOwnPropertyNames(options); + +// Ensure all expected items are in actual and also allow other properties +// implemented in new proposals. +assert(actual.indexOf("locale") > -1, "\"locale\" is present"); +for (var i = 1; i < expected.length; i++) { + // Ensure the order as expected but allow additional new property in between + assert(actual.indexOf(expected[i-1]) < actual.indexOf(expected[i]), `"${expected[i-1]}" precedes "${expected[i]}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js new file mode 100644 index 0000000000..d210777575 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/prop-desc.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Checks the "resolvedOptions" property of the Segmenter prototype object. +info: | + Intl.Segmenter.prototype.resolvedOptions () + + 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.Segmenter] +---*/ + +assert.sameValue( + typeof Intl.Segmenter.prototype.resolvedOptions, + "function", + "typeof Intl.Segmenter.prototype.resolvedOptions is function" +); + +verifyProperty(Intl.Segmenter.prototype, "resolvedOptions", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/shell.js diff --git a/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js new file mode 100644 index 0000000000..b12e734dba --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/prototype/resolvedOptions/type-without-lbs.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.prototype.resolvedOptions +description: Checks the properties of the result of Intl.Segmenter.prototype.resolvedOptions(). +info: | + Intl.Segmenter.prototype.resolvedOptions () + + 3. Let options be ! ObjectCreate(%ObjectPrototype%). + 4. For each row of Table 1, except the header row, do + c. If v is not undefined, then + i. Perform ! CreateDataPropertyOrThrow(options, p, v). +includes: [propertyHelper.js] +features: [Intl.Segmenter] +---*/ + +const rtf = new Intl.Segmenter("en-us", { "lineBreakStyle": "loose", "granularity": "word" }); +const options = rtf.resolvedOptions(); +assert.sameValue(Object.getPrototypeOf(options), Object.prototype, "Prototype"); + +verifyProperty(options, "locale", { + value: "en-US", + writable: true, + enumerable: true, + configurable: true, +}); + +verifyProperty(options, "granularity", { + value: "word", + writable: true, + enumerable: true, + configurable: true, +}); + +verifyProperty(options, "lineBreakStyle", undefined); + +reportCompare(0, 0); |