mirror of
https://github.com/tc39/test262.git
synced 2025-07-12 08:34:41 +02:00
Add Collator test for ignorePunctuation (#3913)
Test the explicit setting of ignorePunctuation in the option bag reflect to the value in resolvedOptions() under Thai and other locales. (Thai is a special case) Test the behavior of the compare sync with the value of resolvedOptions().ignorePunctuation
This commit is contained in:
parent
1bd99bf069
commit
3c9b3913b2
17
test/intl402/Collator/prototype/compare/ignorePunctuation.js
vendored
Normal file
17
test/intl402/Collator/prototype/compare/ignorePunctuation.js
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-collator-comparestrings
|
||||||
|
description: test CompareStrings sync with resolvedOptions().ignorePunctuation.
|
||||||
|
locale: [en, th, ja]
|
||||||
|
---*/
|
||||||
|
// test on three locales, 'th' has different default.
|
||||||
|
['en', 'th', 'ja'].forEach((locale) => {
|
||||||
|
[undefined, true, false].forEach((ignorePunctuation) => {
|
||||||
|
let col = new Intl.Collator(locale, {ignorePunctuation});
|
||||||
|
// if ignorePunctuation is true, the comparison will be 0
|
||||||
|
let expected = col.resolvedOptions().ignorePunctuation ? 0 : -1;
|
||||||
|
assert.sameValue(col.compare("", " "), expected, "Compare to space");
|
||||||
|
assert.sameValue(col.compare("", "*"), expected, "Compare to star");
|
||||||
|
});
|
||||||
|
});
|
15
test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js
vendored
Normal file
15
test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-initializecollator
|
||||||
|
description: resolved ignorePunctuation is the same as the one specified in option bag.
|
||||||
|
locale: [en, th, ja]
|
||||||
|
---*/
|
||||||
|
['en', 'th', 'ja'].forEach((locale) => {
|
||||||
|
[true, false].forEach((ignorePunctuation) => {
|
||||||
|
assert.sameValue(
|
||||||
|
(new Intl.Collator(locale, {ignorePunctuation}))
|
||||||
|
.resolvedOptions().ignorePunctuation,
|
||||||
|
ignorePunctuation);
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user