archives

« Bugzilla Issues Index

#2384 — Update needed for test 15.5.4.9_CE.js, String.prototype.localeCompare


In response to bug 1273, the ES6 draft specification has been updated to require that String.prototype.localeCompare returns 0 when comparing Strings that are considered canonically equivalent by the Unicode standard only if it performs language-sensitive comparisons. This partially invalidates test 15.5.4.9_CE.js, which verifies that canonical equivalence is always respected. The test case needs to be updated to only check for canonical equivalence if localeCompare implements language-sensitive comparisons.

I don't know of a way to determine in general whether localeCompare performs language-sensitive comparisons. However, one feature that's very commonly used in language-sensitive comparisons (even for languages using non-Latin writing systems) is treating upper and lower case Latin characters as similar. A very simple test that catches most language-sensitive implementations is therefore
"a".localeCompare("Z") < 0


Presumably all the 15.5.4.9 tests should be updated to first check if Intl is supported, and if so bail out (since presumably verification of the API's semantics should take place in the Intl402 test suite). I think the following should be a sufficient check to all but guarantee Intl is supported:

try { "".localeCompare("", [{toString: function() { throw 1; }}]) } catch(e) { return true; }

Then, to detect whether the current implementation uses locale-sensitive comparisons, Norbert's proposed check can be employed.


Why should tests be skipped if the internationalization API is implemented? The goal of ECMA-402 section 13 was not to invalidate the corresponding parts of ECMA-262, but to provide additional requirements. All existing tests in Test262 should remain valid.

The change requested here has nothing to do with ECMA-402; it became necessary because a contradiction within ECMA-262 got resolved by the editor in a different way than the test anticipated.