Test removal of default locale fallback in Intl.Locale.p.getCollations - #5092
Closed
ptomato wants to merge 0 commit into
Closed
Test removal of default locale fallback in Intl.Locale.p.getCollations#5092ptomato wants to merge 0 commit into
ptomato wants to merge 0 commit into
Conversation
ptomato
force-pushed
the
ecma402-1072-collation-no-default-locale-fallback
branch
2 times, most recently
from
July 23, 2026 00:34
8e43347 to
fc0cf63
Compare
Member
Author
|
Note JSC fails |
gibson042
approved these changes
Jul 23, 2026
Comment on lines
+17
to
+37
| const testCases = [ | ||
| ["en", "phonebk"], | ||
| ["de", "phonebk"], | ||
| ["zh", "stroke"], | ||
| ["und", "pinyin"], | ||
| ["und", "emoji"], | ||
| ]; | ||
|
|
||
| for (const [tag, collation] of testCases) { | ||
| assert.compareArray( | ||
| new Intl.Locale(`${tag}-u-co-${collation}`).getCollations(), | ||
| [collation], | ||
| `getCollations() for ${tag}-u-co-${collation} returns only ${collation}` | ||
| ); | ||
|
|
||
| assert.compareArray( | ||
| new Intl.Locale(tag, { collation }).getCollations(), | ||
| [collation], | ||
| `getCollations() for ${tag} with { collation: "${collation}" } returns only ${collation}` | ||
| ); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| const testCases = [ | |
| ["en", "phonebk"], | |
| ["de", "phonebk"], | |
| ["zh", "stroke"], | |
| ["und", "pinyin"], | |
| ["und", "emoji"], | |
| ]; | |
| for (const [tag, collation] of testCases) { | |
| assert.compareArray( | |
| new Intl.Locale(`${tag}-u-co-${collation}`).getCollations(), | |
| [collation], | |
| `getCollations() for ${tag}-u-co-${collation} returns only ${collation}` | |
| ); | |
| assert.compareArray( | |
| new Intl.Locale(tag, { collation }).getCollations(), | |
| [collation], | |
| `getCollations() for ${tag} with { collation: "${collation}" } returns only ${collation}` | |
| ); | |
| } | |
| var testCases = [ | |
| ["en", "phonebk"], | |
| ["de", "phonebk"], | |
| ["zh", "stroke"], | |
| ["und", "pinyin"], | |
| ["und", "emoji"] | |
| ]; | |
| for (var i = 0; i < testCases.length; i++) { | |
| var baseName = testCases[i][0]; | |
| var collation = testCases[i][1]; | |
| var fullTag = baseName + "-u-co-" + collation; | |
| assert.compareArray( | |
| new Intl.Locale(fullTag).getCollations(), | |
| [collation], | |
| "getCollations() for " + fullTag + " returns only " + collation | |
| ); | |
| assert.compareArray( | |
| new Intl.Locale(tag, { collation: collation }).getCollations(), | |
| [collation], | |
| "getCollations() for " + tag + " with { collation: " + collation + " } returns only " + collation | |
| ); | |
| } |
Comment on lines
+17
to
+24
| for (const tag of ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]) { | ||
| const collations = new Intl.Locale(tag).getCollations(); | ||
| assert.compareArray( | ||
| collations, | ||
| collations.toSorted(), | ||
| `getCollations() for ${tag} should be sorted in lexicographic code unit order` | ||
| ); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| for (const tag of ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]) { | |
| const collations = new Intl.Locale(tag).getCollations(); | |
| assert.compareArray( | |
| collations, | |
| collations.toSorted(), | |
| `getCollations() for ${tag} should be sorted in lexicographic code unit order` | |
| ); | |
| } | |
| var tags = ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]; | |
| for (var i = 0; i < tags.length; i++) { | |
| var tag = tags[i]; | |
| var collations = new Intl.Locale(tag).getCollations(); | |
| var sortedCollations = new Intl.Locale(tag).getCollations().sort(); | |
| assert.compareArray( | |
| sortedCollations, | |
| collations, | |
| "getCollations() for " + tag + " should be sorted in lexicographic code unit order" | |
| ); | |
| } |
Comment on lines
+16
to
+21
| for (const tag of ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]) { | ||
| const output = new Intl.Locale(tag).getCollations(); | ||
| assert.notSameValue(output.length, 0, `getCollations() for ${tag} has at least one element`); | ||
| assert(!output.includes("standard"), `getCollations() for ${tag} should not contain 'standard'`); | ||
| assert(!output.includes("search"), `getCollations() for ${tag} should not contain 'search'`); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| for (const tag of ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]) { | |
| const output = new Intl.Locale(tag).getCollations(); | |
| assert.notSameValue(output.length, 0, `getCollations() for ${tag} has at least one element`); | |
| assert(!output.includes("standard"), `getCollations() for ${tag} should not contain 'standard'`); | |
| assert(!output.includes("search"), `getCollations() for ${tag} should not contain 'search'`); | |
| } | |
| var tags = ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]; | |
| for (var i = 0; i < tags.length; i++) { | |
| var tag = tags[i]; | |
| var collations = new Intl.Locale(tag).getCollations(); | |
| assert.notSameValue(collations.length, 0, | |
| "getCollations() for " + tag + " has at least one element"); | |
| for (var j = 0; j < collations.length; j++) { | |
| assert.notSameValue(collations[j], "standard", | |
| "getCollations() for " + tag + " must not contain 'standard'"); | |
| assert.notSameValue(collations[j], "search", | |
| "getCollations() for " + tag + " must not contain 'search'"); | |
| } | |
| } |
Comment on lines
+15
to
+20
| for (const tag of ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]) { | ||
| assert( | ||
| Array.isArray(new Intl.Locale(tag).getCollations()), | ||
| `getCollations() for ${tag} should return an array`, | ||
| ); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| for (const tag of ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]) { | |
| assert( | |
| Array.isArray(new Intl.Locale(tag).getCollations()), | |
| `getCollations() for ${tag} should return an array`, | |
| ); | |
| } | |
| var tags = ["ar", "de", "en", "ja", "ko", "sv", "tr", "zh"]; | |
| for (var i = 0; i < tags.length; i++) { | |
| var tag = tags[i]; | |
| assert( | |
| Array.isArray(new Intl.Locale(tag).getCollations()), | |
| "getCollations() for " + tag + " must return an array" | |
| ); | |
| } |
Comment on lines
+20
to
+41
| const undLocales = [ | ||
| "und", | ||
| "und-US", | ||
| "und-Latn", | ||
| "und-Latn-US", | ||
| "und-u-ca-gregory", | ||
| "und-US-u-nu-latn", | ||
| ]; | ||
|
|
||
| for (const tag of undLocales) { | ||
| const locale = new Intl.Locale(tag); | ||
| assert.sameValue( | ||
| locale.language, | ||
| "und", | ||
| `"${tag}" has language subtag "und"` | ||
| ); | ||
| assert.compareArray( | ||
| locale.getCollations(), | ||
| ["emoji", "eor"], | ||
| `getCollations() for "${tag}" returns the root collations` | ||
| ); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| const undLocales = [ | |
| "und", | |
| "und-US", | |
| "und-Latn", | |
| "und-Latn-US", | |
| "und-u-ca-gregory", | |
| "und-US-u-nu-latn", | |
| ]; | |
| for (const tag of undLocales) { | |
| const locale = new Intl.Locale(tag); | |
| assert.sameValue( | |
| locale.language, | |
| "und", | |
| `"${tag}" has language subtag "und"` | |
| ); | |
| assert.compareArray( | |
| locale.getCollations(), | |
| ["emoji", "eor"], | |
| `getCollations() for "${tag}" returns the root collations` | |
| ); | |
| } | |
| var undLocales = [ | |
| "und", | |
| "und-US", | |
| "und-Latn", | |
| "und-Latn-US", | |
| "und-u-ca-gregory", | |
| "und-US-u-nu-latn", | |
| ]; | |
| for (var i = 0; i < undLocales.length; i++) { | |
| var tag = undLocales[i]; | |
| var locale = new Intl.Locale(tag); | |
| assert.sameValue( | |
| locale.language, | |
| "und", | |
| tag + " must have language subtag 'und'" | |
| ); | |
| assert.compareArray( | |
| locale.getCollations(), | |
| ["emoji", "eor"], | |
| "getCollations() for " + tag + " must return the root collations" | |
| ); | |
| } |
Comment on lines
+55
to
+61
| for (const tag of ["qfz", "qga-DE", "qgb-ES", "qgc-KR", "qtz-CN"]) { | ||
| assert.compareArray( | ||
| new Intl.Locale(tag).getCollations(), | ||
| ["emoji", "eor"], | ||
| `getCollations() for unavailable locale "${tag}" returns the root collations` | ||
| ); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| for (const tag of ["qfz", "qga-DE", "qgb-ES", "qgc-KR", "qtz-CN"]) { | |
| assert.compareArray( | |
| new Intl.Locale(tag).getCollations(), | |
| ["emoji", "eor"], | |
| `getCollations() for unavailable locale "${tag}" returns the root collations` | |
| ); | |
| } | |
| var privateUseTags = ["qfz", "qga-DE", "qgb-ES", "qgc-KR", "qtz-CN"]; | |
| for (var i = 0; i < privateUseTags.length; i++) { | |
| var tag = privateUseTags[i]; | |
| assert.compareArray( | |
| new Intl.Locale(tag).getCollations(), | |
| ["emoji", "eor"], | |
| "getCollations() for unavailable locale " + tag + " must return the root collations" | |
| ); | |
| } |
gibson042
force-pushed
the
ecma402-1072-collation-no-default-locale-fallback
branch
from
July 23, 2026 18:59
1f90090 to
9e61c12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds baseline tests for the return value of Intl.Locale.p.getCollations() reflecting the situation before normative PR tc39/ecma402#1072 in the first commit, and in the second commit makes the necessary changes for the normative PR.
Note that because the default locale is out-of-band,
und-locale.jsmight pass or fail if the normative change is not implemented, depending on what the environment's default locale is. It should always pass regardless of the environment's default locale if the normative change is implemented correctly. Try running it withLC_ALL=dein the environment, for example.