diff --git a/test/intl402/Collator/prototype/compare/ignorePunctuation.js b/test/intl402/Collator/prototype/compare/ignorePunctuation.js new file mode 100644 index 0000000000..91b05396f3 --- /dev/null +++ b/test/intl402/Collator/prototype/compare/ignorePunctuation.js @@ -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"); + }); +}); diff --git a/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js b/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js new file mode 100644 index 0000000000..2dabdaf96f --- /dev/null +++ b/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js @@ -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); + }); +});