Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --icu_case_mapping | 5 // Flags: --icu_case_mapping |
| 6 | 6 |
| 7 // Some edge cases that unibrow got wrong | 7 // Some edge cases that unibrow got wrong |
| 8 | 8 |
| 9 assertEquals("𐐘", "𐑀".toUpperCase()); | 9 assertEquals("𐐘", "𐑀".toUpperCase()); |
| 10 assertEquals("𐑀", "𐐘".toLowerCase()); | 10 assertEquals("𐑀", "𐐘".toLowerCase()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 assertEquals("\u{1D400}\u{1D41A}", "\u{1D400}\u{1D41A}".toUpperCase()); | 129 assertEquals("\u{1D400}\u{1D41A}", "\u{1D400}\u{1D41A}".toUpperCase()); |
| 130 assertEquals("\u{1D400}\u{1D41A}", "\u{1D400}\u{1D41A}".toLowerCase()); | 130 assertEquals("\u{1D400}\u{1D41A}", "\u{1D400}\u{1D41A}".toLowerCase()); |
| 131 // Plane 1; New characters in Unicode 8.0 | 131 // Plane 1; New characters in Unicode 8.0 |
| 132 assertEquals("\u{10C80}", "\u{10CC0}".toUpperCase()); | 132 assertEquals("\u{10C80}", "\u{10CC0}".toUpperCase()); |
| 133 assertEquals("\u{10CC0}", "\u{10C80}".toLowerCase()); | 133 assertEquals("\u{10CC0}", "\u{10C80}".toLowerCase()); |
| 134 assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase()); | 134 assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase()); |
| 135 assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase()); | 135 assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase()); |
| 136 assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"])); | 136 assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"])); |
| 137 assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"])); | 137 assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"])); |
| 138 assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase()); | 138 assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase()); |
| 139 | |
| 140 // If the result of case mapping is longer than the max string length | |
| 141 // (1<<28 - 16), it should throw a range error instead of crashing. | |
| 142 var invalidValues = [ | |
| 143 { s: "\u0390", opType: 0 }, | |
| 144 { s: "ß", opType: 0 }, | |
| 145 { s: "\uFB01", opType: 0 }, // fi ligature | |
| 146 { s: "\uFB04", opType: 0 }, // ffl ligature | |
| 147 { s: "\u0390", opType: 1, locale: "und" }, | |
| 148 { s: "\u00CC", opType: 2, locale: "lt" }, | |
| 149 { s: "\u0130", opType: 2, locale: "en" }, | |
| 150 ]; | |
| 151 | |
| 152 invalidValues.forEach(function(value) { | |
|
Dan Ehrenberg
2016/08/10 19:06:23
Wouldn't this be a great place to use destructurin
| |
| 153 var error; | |
| 154 try { | |
| 155 var s = value.s.repeat(1<<27); | |
| 156 switch (value.opType) { | |
| 157 case 0: | |
| 158 s.toUpperCase(); | |
| 159 break; | |
| 160 case 1: | |
| 161 s.toLocaleUpperCase(value.locale); | |
| 162 break; | |
| 163 case 2: | |
| 164 s.toLocaleLowerCase(value.locale); | |
| 165 break; | |
| 166 } | |
| 167 } catch (e) { | |
| 168 error = e; | |
| 169 } | |
| 170 | |
| 171 assertTrue(error !== undefined); | |
| 172 assertEquals('RangeError', error.name); | |
|
Dan Ehrenberg
2016/08/10 19:08:02
You could also do assertThrows(() => s.toLocaleUpp
| |
| 173 }); | |
| OLD | NEW |