mirror of https://github.com/tc39/test262.git
15.5.4.9_CE should check for locale-sensitive comparison
This commit is contained in:
parent
9b669da66c
commit
47a92dbb24
|
@ -1,5 +1,6 @@
|
||||||
// Copyright 2012 Norbert Lindenberg. All rights reserved.
|
// Copyright 2012 Norbert Lindenberg. All rights reserved.
|
||||||
// Copyright 2012 Mozilla Corporation. 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.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +47,9 @@ var pairs = [
|
||||||
// ["\uD87E\uDC2B", "北"]
|
// ["\uD87E\uDC2B", "北"]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 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;
|
var i;
|
||||||
for (i = 0; i < pairs.length; i++) {
|
for (i = 0; i < pairs.length; i++) {
|
||||||
var pair = pairs[i];
|
var pair = pairs[i];
|
||||||
|
@ -54,6 +58,17 @@ for (i = 0; i < pairs.length; i++) {
|
||||||
") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
|
") ≠ " + 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]) + ").");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toU(s) {
|
function toU(s) {
|
||||||
var result = "";
|
var result = "";
|
||||||
|
@ -65,4 +80,3 @@ function toU(s) {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue