-
Notifications
You must be signed in to change notification settings - Fork 516
Add tests for Intl.Locale.prototype.variants #4474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8475efc to
bb37a1e
Compare
|
tc39/ecma402#960 reached consensus in TC39 plenary, and has been merged into ECMA-402. This can be merged as soon as it has a review (which should be relatively low effort, especially if going by commit-by-commit). |
| ]; | ||
| for (const [lang, variants, baseName] of validVariantsOptions) { | ||
| let options = { variants }; | ||
| let optionsRepr = `{variants: ${variants == null ? variants : `"${variants}"`}}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: the == operator here is very subtle but actually significant and needed. I overlooked it in several reads, and thought the code looked wrong. Would there be a more obvious way to write it?
anba
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe also test canonicalisation works correctly when the variants option is used:
- Variant subtags are correctly sorted:
js> new Intl.Locale("en", {variants: "spanglis-oxendict"}).toString()
"en-oxendict-spanglis"- Deprecated language tags are canonicalised to their modern form:
js> new Intl.Locale("cel", {variants: "gaulish"}).toString()
"xtg"| "3xy", | ||
| "abcd", | ||
| "12345", | ||
| "5wxyz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"12345" and "5wxyz" are both valid variant subtags.
|
|
||
| // Value contains more than just the 'variants' production. | ||
| "GB-scouse", | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also test for leading, trailing, and consecutive "-"?
const alsoInvalid = [
"-",
"-spanglis",
"spanglis-",
"-spanglis-oxendict",
"spanglis-oxendict-",
"spanglis--oxendict",
];There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And test that duplicate variants throw:
js> new Intl.Locale("en", {variants: "spanglis-spanglis"})
typein:1:1 RangeError: duplicate variant subtag|
Thanks for the great comments. This is ready for re-review. |
|
LGTM! I've confirmed all tests pass with the patches from https://bugzilla.mozilla.org/show_bug.cgi?id=1970161 applied. |
1d70af5 to
bbdd4a8
Compare
* Add a helper for concision * Specify properties in a different order than the one used for reading
https://bugs.webkit.org/show_bug.cgi?id=294755 Reviewed by NOBODY (OOPS!). tc39/ecma402#960 added `Intl.Locale.prototype.variants` to the ECMAScript specification. The test262 test suite has also been updated [1]. This patch implements `Intl.Locale.prototype.variants` for JSC. [1]: tc39/test262#4474 * JSTests/stress/intl-locale-prototype-variants.js: Added. (shouldBe): (shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/CommonIdentifiers.h: * Source/JavaScriptCore/runtime/IntlLocale.cpp: (JSC::LocaleIDBuilder::overrideLanguageScriptRegionVariants): (JSC::IntlLocale::initializeLocale): (JSC::IntlLocale::variants): (JSC::LocaleIDBuilder::overrideLanguageScriptRegion): Deleted. * Source/JavaScriptCore/runtime/IntlLocale.h: * Source/JavaScriptCore/runtime/IntlLocalePrototype.cpp: (JSC::JSC_DEFINE_CUSTOM_GETTER):
https://bugs.webkit.org/show_bug.cgi?id=294755 Reviewed by Yusuke Suzuki. tc39/ecma402#960 added `Intl.Locale.prototype.variants` to the ECMAScript specification. The test262 test suite has also been updated [1]. This patch implements `Intl.Locale.prototype.variants` for JSC. [1]: tc39/test262#4474 * JSTests/stress/intl-locale-prototype-variants.js: Added. (shouldBe): (shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/CommonIdentifiers.h: * Source/JavaScriptCore/runtime/IntlLocale.cpp: (JSC::LocaleIDBuilder::overrideLanguageScriptRegionVariants): (JSC::IntlLocale::initializeLocale): (JSC::IntlLocale::variants): (JSC::LocaleIDBuilder::overrideLanguageScriptRegion): Deleted. * Source/JavaScriptCore/runtime/IntlLocale.h: * Source/JavaScriptCore/runtime/IntlLocalePrototype.cpp: (JSC::JSC_DEFINE_CUSTOM_GETTER): Canonical link: https://commits.webkit.org/296467@main
https://tc39.es/ecma402/#sec-Intl.Locale.prototype.variants Added to the spec by tc39/ecma402#960 Test code added in tc39/test262#4474 feature https://chromestatus.com/feature/4709921706868736 I2P https://groups.google.com/a/chromium.org/g/blink-dev/c/NCT4pPJ_Uz8/m/G62K-m6CAgAJ Bug: 450083673 Change-Id: I49a4af9f9e75a18efb3b67f546f971d4c24e0bb0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7018878 Reviewed-by: Leszek Swirski <[email protected]> Reviewed-by: Olivier Flückiger <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#103188}
https://tc39.es/ecma402/#sec-Intl.Locale.prototype.variants Added to the spec by tc39/ecma402#960 Test code added in tc39/test262#4474 feature https://chromestatus.com/feature/4709921706868736 I4DT https://groups.google.com/a/chromium.org/g/blink-dev/c/i6QEHcH_fiI/m/4xUyZbSvAAAJ Bug: 450083673 Change-Id: I987b3066726323550d098222e50da999c145495c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7064530 Commit-Queue: Frank Tang <[email protected]> Reviewed-by: Rezvan Mahdavi Hezaveh <[email protected]> Cr-Commit-Position: refs/heads/main@{#103233}
Ref tc39/ecma402#960