mirror of https://github.com/tc39/test262.git
Change Intl.(ListFormat|DisplayNames|Segmenter) (#2952)
* Change Intl.(ListFormat|DisplayNames|Segmenter) Sync from ToObject to GetOptionsObject which throw TypeError while the option is not object * Add null and false to test
This commit is contained in:
parent
aca79695ba
commit
31126581e7
|
@ -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) })
|
||||||
|
}
|
|
@ -6,21 +6,19 @@ esid: sec-Intl.ListFormat
|
||||||
description: Checks handling of non-object option arguments to the ListFormat constructor.
|
description: Checks handling of non-object option arguments to the ListFormat constructor.
|
||||||
info: |
|
info: |
|
||||||
InitializeListFormat (listFormat, locales, options)
|
InitializeListFormat (listFormat, locales, options)
|
||||||
features: [Intl.ListFormat]
|
features: [Intl.ListFormat,BigInt]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const optionsArguments = [
|
const optionsArguments = [
|
||||||
|
null,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
"test",
|
"test",
|
||||||
7,
|
7,
|
||||||
Symbol(),
|
Symbol(),
|
||||||
|
123456789n,
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const options of optionsArguments) {
|
for (const options of optionsArguments) {
|
||||||
const lf = new Intl.ListFormat([], options);
|
assert.throws(TypeError, function() { 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"`);
|
|
||||||
}
|
}
|
|
@ -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"`);
|
|
||||||
}
|
|
|
@ -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) })
|
||||||
|
}
|
|
@ -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"`);
|
|
||||||
}
|
|
|
@ -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"`);
|
|
||||||
}
|
|
Loading…
Reference in New Issue