diff --git a/test/intl402/DisplayNames/options-getoptionsobject.js b/test/intl402/DisplayNames/options-getoptionsobject.js new file mode 100644 index 0000000000..174416b4f1 --- /dev/null +++ b/test/intl402/DisplayNames/options-getoptionsobject.js @@ -0,0 +1,24 @@ +// Copyright 2021 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DisplayNames +description: Checks handling of non-object option arguments to the DisplayNames constructor. +info: | + Intl.DisplayNames ( locales, options ) +features: [Intl.DisplayNames,BigInt] +---*/ + +const optionsArguments = [ + null, + true, + false, + "test", + 7, + Symbol(), + 123456789n, +]; + +for (const options of optionsArguments) { + assert.throws(TypeError, function() { new Intl.DisplayNames([], options) }) +} diff --git a/test/intl402/ListFormat/constructor/constructor/options-toobject.js b/test/intl402/ListFormat/constructor/constructor/options-getoptionsobject.js similarity index 51% rename from test/intl402/ListFormat/constructor/constructor/options-toobject.js rename to test/intl402/ListFormat/constructor/constructor/options-getoptionsobject.js index 74e8603309..4886b85944 100644 --- a/test/intl402/ListFormat/constructor/constructor/options-toobject.js +++ b/test/intl402/ListFormat/constructor/constructor/options-getoptionsobject.js @@ -6,21 +6,19 @@ esid: sec-Intl.ListFormat description: Checks handling of non-object option arguments to the ListFormat constructor. info: | InitializeListFormat (listFormat, locales, options) -features: [Intl.ListFormat] +features: [Intl.ListFormat,BigInt] ---*/ const optionsArguments = [ + null, true, + false, "test", 7, Symbol(), + 123456789n, ]; for (const options of optionsArguments) { - const lf = new Intl.ListFormat([], options); - const resolvedOptions = lf.resolvedOptions(); - assert.sameValue(resolvedOptions.type, "conjunction", - `options argument ${String(options)} should yield the correct value for "type"`); - assert.sameValue(resolvedOptions.style, "long", - `options argument ${String(options)} should yield the correct value for "style"`); + assert.throws(TypeError, function() { new Intl.ListFormat([], options) }) } diff --git a/test/intl402/ListFormat/constructor/constructor/options-toobject-prototype.js b/test/intl402/ListFormat/constructor/constructor/options-toobject-prototype.js deleted file mode 100644 index da0667aad6..0000000000 --- a/test/intl402/ListFormat/constructor/constructor/options-toobject-prototype.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-Intl.ListFormat -description: Checks handling of non-object option arguments to the ListFormat constructor. -info: | - InitializeListFormat (listFormat, locales, options) -features: [Intl.ListFormat] ----*/ - -Object.defineProperties(Object.prototype, { - "type": { - value: "unit", - }, - "style": { - value: "short", - }, -}) - -const optionsArguments = [ - true, - "test", - 7, - Symbol(), -]; - -for (const options of optionsArguments) { - const lf = new Intl.ListFormat([], options); - const resolvedOptions = lf.resolvedOptions(); - assert.sameValue(resolvedOptions.type, "unit", - `options argument ${String(options)} should yield the correct value for "type"`); - assert.sameValue(resolvedOptions.style, "short", - `options argument ${String(options)} should yield the correct value for "style"`); -} diff --git a/test/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js b/test/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js new file mode 100644 index 0000000000..39128e3cf3 --- /dev/null +++ b/test/intl402/Segmenter/constructor/constructor/options-getoptionsobject.js @@ -0,0 +1,25 @@ +// 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 +description: Checks handling of non-object option arguments to the Segmenter constructor. +info: | + Intl.Segmenter ([ locales [ , options ]]) + +features: [Intl.Segmenter,BigInt] +---*/ + +const optionsArguments = [ + null, + true, + false, + "test", + 7, + Symbol(), + 123456789n, +]; + +for (const options of optionsArguments) { + assert.throws(TypeError, function() { new Intl.Segment([], options) }) +} diff --git a/test/intl402/Segmenter/constructor/constructor/options-toobject-prototype.js b/test/intl402/Segmenter/constructor/constructor/options-toobject-prototype.js deleted file mode 100644 index 891b0778e0..0000000000 --- a/test/intl402/Segmenter/constructor/constructor/options-toobject-prototype.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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 -description: Checks handling of non-object option arguments to the Segmenter constructor. -info: | - Intl.Segmenter ([ locales [ , options ]]) - - 5. Else - a. Let options be ? ToObject(options). -features: [Intl.Segmenter] ----*/ - -Object.defineProperties(Object.prototype, { - "granularity": { - value: "word", - }, -}) - -const optionsArguments = [ - true, - "test", - 7, - Symbol(), - {}, -]; - -for (const options of optionsArguments) { - const segmenter = new Intl.Segmenter([], options); - const resolvedOptions = segmenter.resolvedOptions(); - assert.sameValue(resolvedOptions.granularity, "word", - `options argument ${String(options)} should yield the correct value for "granularity"`); -} diff --git a/test/intl402/Segmenter/constructor/constructor/options-toobject.js b/test/intl402/Segmenter/constructor/constructor/options-toobject.js deleted file mode 100644 index ab3b6230c8..0000000000 --- a/test/intl402/Segmenter/constructor/constructor/options-toobject.js +++ /dev/null @@ -1,30 +0,0 @@ -// 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 -description: Checks handling of non-object option arguments to the Segmenter constructor. -info: | - Intl.Segmenter ([ locales [ , options ]]) - - 5. Else - a. Let options be ? ToObject(options). -features: [Intl.Segmenter] ----*/ - -const optionsArguments = [ - true, - "test", - 7, - Symbol(), - {}, -]; - -for (const options of optionsArguments) { - const segmenter = new Intl.Segmenter([], options); - const resolvedOptions = segmenter.resolvedOptions(); - assert.sameValue(resolvedOptions.granularity, "grapheme", - `options argument ${String(options)} should yield the correct value for "granularity"`); - assert.sameValue(resolvedOptions.lineBreakStyle, undefined, - `options argument ${String(options)} should yield the correct value for "lineBreakStyle"`); -}