mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 05:55:36 +02:00
Merge pull request #2119 from FrankYFTang/patch-2
Update test to allow 'narrow' style for all types
This commit is contained in:
commit
324f2916d3
@ -1,22 +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 invalid value for the type option to the ListFormat constructor.
|
|
||||||
info: |
|
|
||||||
InitializeListFormat (listFormat, locales, options)
|
|
||||||
7. Let type be GetOption(options, "type", "string", « "conjunction", "disjunction", "unit" », "conjunction").
|
|
||||||
features: [Intl.ListFormat]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const invalidTypes = [
|
|
||||||
"conjunction",
|
|
||||||
"disjunction",
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const type of invalidTypes) {
|
|
||||||
assert.throws(RangeError, function() {
|
|
||||||
new Intl.ListFormat([], { style: "narrow", type });
|
|
||||||
}, `${type} is an invalid type option value when style is narrow.`);
|
|
||||||
}
|
|
@ -6,9 +6,13 @@ esid: sec-Intl.ListFormat
|
|||||||
description: Checks handling of valid values for the style option to the ListFormat constructor.
|
description: Checks handling of valid values for the style option to the ListFormat constructor.
|
||||||
info: |
|
info: |
|
||||||
InitializeListFormat (listFormat, locales, options)
|
InitializeListFormat (listFormat, locales, options)
|
||||||
9. Let s be ? GetOption(options, "style", "string", «"long", "short", "narrow"», "long").
|
InitializeListFormat (listFormat, locales, options)
|
||||||
10. Set listFormat.[[Style]] to s.
|
12. Let type be ? GetOption(options, "type", "string", « "conjunction",
|
||||||
14. If style is "narrow" and type is not "unit", throw a RangeError exception.
|
"disjunction", "unit" », "conjunction").
|
||||||
|
13. Set listFormat.[[Type]] to type.
|
||||||
|
14. Let style be ? GetOption(options, "style", "string", « "long", "short",
|
||||||
|
"narrow" », "long").
|
||||||
|
15. Set listFormat.[[Style]] to style.
|
||||||
features: [Intl.ListFormat]
|
features: [Intl.ListFormat]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -16,7 +20,10 @@ const validOptions = [
|
|||||||
[undefined, "long"],
|
[undefined, "long"],
|
||||||
["long", "long"],
|
["long", "long"],
|
||||||
["short", "short"],
|
["short", "short"],
|
||||||
|
["narrow", "narrow"],
|
||||||
[{ toString() { return "short"; } }, "short"],
|
[{ toString() { return "short"; } }, "short"],
|
||||||
|
[{ toString() { return "long"; } }, "long"],
|
||||||
|
[{ toString() { return "narrow"; } }, "narrow"],
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const [validOption, expected] of validOptions) {
|
for (const [validOption, expected] of validOptions) {
|
||||||
@ -24,11 +31,3 @@ for (const [validOption, expected] of validOptions) {
|
|||||||
const resolvedOptions = lf.resolvedOptions();
|
const resolvedOptions = lf.resolvedOptions();
|
||||||
assert.sameValue(resolvedOptions.style, expected);
|
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"}));
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user