diff --git a/test/intl402/ListFormat/constructor/constructor/options-style-valid.js b/test/intl402/ListFormat/constructor/constructor/options-style-valid.js index ba699978ea0678a9d29b6b3d249ac34652974def..01d1cd8ee6f91e17f13028be9816efe9af3281ef 100644 --- a/test/intl402/ListFormat/constructor/constructor/options-style-valid.js +++ b/test/intl402/ListFormat/constructor/constructor/options-style-valid.js @@ -8,6 +8,7 @@ info: | InitializeListFormat (listFormat, locales, options) 9. Let s be ? GetOption(options, "style", "string", «"long", "short", "narrow"», "long"). 10. Set listFormat.[[Style]] to s. + 14. If style is "narrow" and type is not "unit", throw a RangeError exception. features: [Intl.ListFormat] ---*/ @@ -15,8 +16,7 @@ const validOptions = [ [undefined, "long"], ["long", "long"], ["short", "short"], - ["narrow", "narrow"], - [{ toString() { return "narrow"; } }, "narrow"], + [{ toString() { return "short"; } }, "short"], ]; for (const [validOption, expected] of validOptions) { @@ -24,3 +24,11 @@ for (const [validOption, expected] of validOptions) { const resolvedOptions = lf.resolvedOptions(); assert.sameValue(resolvedOptions.style, expected); } + +const lf = new Intl.ListFormat([], {"style": "narrow", "type": "unit"}); +const resolvedOptions = lf.resolvedOptions(); +assert.sameValue(resolvedOptions.style, "narrow"); + +assert.throws(RangeError, () => lf = new Intl.ListFormat([], {"style": "narrow"})); +assert.throws(RangeError, () => lf = new Intl.ListFormat([], {"style": "narrow", "type": "conjuction"})); +assert.throws(RangeError, () => lf = new Intl.ListFormat([], {"style": "narrow", "type": "disjuction"})); diff --git a/test/intl402/ListFormat/prototype/format/en-us-narrow.js b/test/intl402/ListFormat/prototype/format/en-us-narrow.js index 17a6bba49c002ac31409cc8df613062bbd23b6c2..dbe6792d6a56a29825b33e85c8dcbfa8c55f9677 100644 --- a/test/intl402/ListFormat/prototype/format/en-us-narrow.js +++ b/test/intl402/ListFormat/prototype/format/en-us-narrow.js @@ -38,6 +38,7 @@ const transforms = [ const lf = new Intl.ListFormat("en-US", { "style": "narrow", + "type": "unit", }); assert.sameValue(typeof lf.format, "function", "format should be supported"); @@ -45,9 +46,9 @@ assert.sameValue(typeof lf.format, "function", "format should be supported"); for (const f of transforms) { assert.sameValue(lf.format(f([])), ""); assert.sameValue(lf.format(f(["foo"])), "foo"); - assert.sameValue(lf.format(f(["foo", "bar"])), "foo and bar"); - assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, and baz"); - assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, and quux"); + assert.sameValue(lf.format(f(["foo", "bar"])), "foo bar"); + assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo bar baz"); + assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo bar baz quux"); } -assert.sameValue(lf.format("foo"), "f, o, and o"); +assert.sameValue(lf.format("foo"), "f o o"); diff --git a/test/intl402/ListFormat/prototype/formatToParts/en-us-narrow.js b/test/intl402/ListFormat/prototype/formatToParts/en-us-narrow.js index 891c8fb372b65983dd025d536941e13c6d30ee3b..6d4e7c16e8f3cb8e4d6c9ba034c25c898891de44 100644 --- a/test/intl402/ListFormat/prototype/formatToParts/en-us-narrow.js +++ b/test/intl402/ListFormat/prototype/formatToParts/en-us-narrow.js @@ -47,6 +47,7 @@ const transforms = [ const lf = new Intl.ListFormat("en-US", { "style": "narrow", + "type": "unit", }); assert.sameValue(typeof lf.formatToParts, "function", "formatToParts should be supported"); @@ -58,31 +59,31 @@ for (const f of transforms) { ]); verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [ { "type": "element", "value": "foo" }, - { "type": "literal", "value": " and " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "bar" }, ]); verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [ { "type": "element", "value": "foo" }, - { "type": "literal", "value": ", " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "bar" }, - { "type": "literal", "value": ", and " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "baz" }, ]); verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [ { "type": "element", "value": "foo" }, - { "type": "literal", "value": ", " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "bar" }, - { "type": "literal", "value": ", " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "baz" }, - { "type": "literal", "value": ", and " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "quux" }, ]); } verifyFormatParts(lf.formatToParts("foo"), [ { "type": "element", "value": "f" }, - { "type": "literal", "value": ", " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "o" }, - { "type": "literal", "value": ", and " }, + { "type": "literal", "value": " " }, { "type": "element", "value": "o" }, ]);