diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-toobject-prototype.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-toobject-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..f7a8c04048da77e43ee528eb7888b4ff5166b5e7 --- /dev/null +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-toobject-prototype.js @@ -0,0 +1,35 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat +description: Checks handling of non-object option arguments to the RelativeTimeFormat constructor. +info: | + InitializeRelativeTimeFormat (relativeTimeFormat, locales, options) +features: [Intl.RelativeTimeFormat] +---*/ + +Object.defineProperties(Object.prototype, { + "style": { + value: "short", + }, + "numeric": { + value: "auto", + }, +}) + +const optionsArguments = [ + true, + "test", + 7, + Symbol(), +]; + +for (const options of optionsArguments) { + const rtf = new Intl.RelativeTimeFormat([], options); + const resolvedOptions = rtf.resolvedOptions(); + assert.sameValue(resolvedOptions.style, "short", + `options argument ${String(options)} should yield the correct value for "style"`); + assert.sameValue(resolvedOptions.numeric, "auto", + `options argument ${String(options)} should yield the correct value for "numeric"`); +} diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-toobject.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-toobject.js new file mode 100644 index 0000000000000000000000000000000000000000..796bfaa2b04ba3f37b720440d7e6a855257fc1df --- /dev/null +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-toobject.js @@ -0,0 +1,26 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat +description: Checks handling of non-object option arguments to the RelativeTimeFormat constructor. +info: | + InitializeRelativeTimeFormat (relativeTimeFormat, locales, options) +features: [Intl.RelativeTimeFormat] +---*/ + +const optionsArguments = [ + true, + "test", + 7, + Symbol(), +]; + +for (const options of optionsArguments) { + const rtf = new Intl.RelativeTimeFormat([], options); + const resolvedOptions = rtf.resolvedOptions(); + assert.sameValue(resolvedOptions.style, "long", + `options argument ${String(options)} should yield the correct value for "style"`); + assert.sameValue(resolvedOptions.numeric, "always", + `options argument ${String(options)} should yield the correct value for "numeric"`); +} diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..f5ab4bf838bfb2bbbb3b0f1d244445f84ed1c085 --- /dev/null +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-undefined.js @@ -0,0 +1,38 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat +description: Checks handling of non-object option arguments to the RelativeTimeFormat constructor. +info: | + InitializeRelativeTimeFormat (relativeTimeFormat, locales, options) +features: [Intl.RelativeTimeFormat] +---*/ + +Object.defineProperties(Object.prototype, { + "style": { + get() { + throw new Error("Should not call style getter"); + } + }, + "numeric": { + get() { + throw new Error("Should not call numeric getter"); + } + }, +}) + +const optionsArguments = [ + [], + [[]], + [[], undefined], +]; + +for (const args of optionsArguments) { + const rtf = new Intl.RelativeTimeFormat(...args); + const resolvedOptions = rtf.resolvedOptions(); + assert.sameValue(resolvedOptions.style, "long", + `Calling with ${args.length} empty arguments should yield the correct value for "style"`); + assert.sameValue(resolvedOptions.numeric, "always", + `Calling with ${args.length} empty arguments should yield the correct value for "numeric"`); +}