Skip to content
Snippets Groups Projects
Commit b0c6fb02 authored by Brian Terlson's avatar Brian Terlson
Browse files

Merge pull request #2 from bterlson/localeCompare-fix

15.5.4.9_CE should check for locale-sensitive comparison
parents e7f4a5c3 47a92dbb
No related branches found
No related tags found
No related merge requests found
// Copyright 2012 Norbert Lindenberg. All rights reserved.
// Copyright 2012 Mozilla Corporation. All rights reserved.
// Copyright 2013 Microsoft Corporation. All rights reserved.
// This code is governed by the license found in the LICENSE file.
/**
......@@ -46,12 +47,26 @@ var pairs = [
// ["\uD87E\uDC2B", "北"]
];
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
if (pair[0].localeCompare(pair[1]) !== 0) {
$ERROR("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) +
") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
// Detect whether we are using locale-sensitive comparisons or a bitwise comparison
if("a".localeCompare("Z") < 0) {
// We are using locale-sensitive comparison, so all pairs should be canonically equivalent
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
if (pair[0].localeCompare(pair[1]) !== 0) {
$ERROR("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) +
") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
}
}
} else {
// We are using bitwise comparison, so all pairs should not be equivalent
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
if (pair[0].localeCompare(pair[1]) === 0) {
$ERROR("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) +
") = " + pair[1] + " (" + toU(pair[1]) + ").");
}
}
}
......@@ -65,4 +80,3 @@ function toU(s) {
}
return result;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment