|
1 | 1 | // Copyright 2012 Norbert Lindenberg. All rights reserved.
|
2 | 2 | // Copyright 2012 Mozilla Corporation. All rights reserved.
|
3 | 3 | // Copyright 2013 Microsoft Corporation. All rights reserved.
|
| 4 | +// Copyright (C) 2022 Richard Gibson. All rights reserved. |
4 | 5 | // This code is governed by the license found in the LICENSE file.
|
5 | 6 |
|
6 | 7 | /*---
|
7 |
| -es5id: 15.5.4.9_CE |
8 | 8 | description: >
|
9 |
| - Tests that String.prototype.localeCompare returns 0 when |
10 |
| - comparing Strings that are considered canonically equivalent by |
11 |
| - the Unicode standard. |
12 |
| -author: Norbert Lindenberg |
| 9 | + String.prototype.localeCompare must return 0 when |
| 10 | + comparing Strings that are considered canonically equivalent by |
| 11 | + the Unicode Standard. |
| 12 | +esid: sec-string.prototype.localecompare |
| 13 | +info: | |
| 14 | + String.prototype.localeCompare ( _that_ [ , _reserved1_ [ , _reserved2_ ] ] ) |
| 15 | +
|
| 16 | + This function must treat Strings that are canonically equivalent |
| 17 | + according to the Unicode standard as identical and must return `0` |
| 18 | + when comparing Strings that are considered canonically equivalent. |
13 | 19 | ---*/
|
14 | 20 |
|
15 | 21 | // pairs with characters not in Unicode 3.0 are commented out
|
@@ -49,26 +55,12 @@ var pairs = [
|
49 | 55 | // ["\uD87E\uDC2B", "北"]
|
50 | 56 | ];
|
51 | 57 |
|
52 |
| -// Detect whether we are using locale-sensitive comparisons or a bitwise comparison |
53 |
| -if ("a".localeCompare("Z") < 0) { |
54 |
| - // We are using locale-sensitive comparison, so all pairs should be canonically equivalent |
55 |
| - var i; |
56 |
| - for (i = 0; i < pairs.length; i++) { |
57 |
| - var pair = pairs[i]; |
58 |
| - if (pair[0].localeCompare(pair[1]) !== 0) { |
59 |
| - throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) + |
60 |
| - ") ≠ " + pair[1] + " (" + toU(pair[1]) + ")."); |
61 |
| - } |
62 |
| - } |
63 |
| -} else { |
64 |
| - // We are using bitwise comparison, so all pairs should not be equivalent |
65 |
| - var i; |
66 |
| - for (i = 0; i < pairs.length; i++) { |
67 |
| - var pair = pairs[i]; |
68 |
| - if (pair[0].localeCompare(pair[1]) === 0) { |
69 |
| - throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) + |
70 |
| - ") = " + pair[1] + " (" + toU(pair[1]) + ")."); |
71 |
| - } |
| 58 | +var i; |
| 59 | +for (i = 0; i < pairs.length; i++) { |
| 60 | + var pair = pairs[i]; |
| 61 | + if (pair[0].localeCompare(pair[1]) !== 0) { |
| 62 | + throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) + |
| 63 | + ") ≠ " + pair[1] + " (" + toU(pair[1]) + ")."); |
72 | 64 | }
|
73 | 65 | }
|
74 | 66 |
|
|
0 commit comments