Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: test/intl/general/case-mapping.js

Issue 2236593002: Throw when case mapping result > max string length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: AssertThrows and destructuring Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 { c: "\u0390", opType: 0 },
144 { c: "ß", opType: 0 },
145 { c: "\uFB01", opType: 0 }, // fi ligature
146 { c: "\uFB04", opType: 0 }, // ffl ligature
147 { c: "\u0390", opType: 1, locale: "und" },
148 { c: "\u00CC", opType: 2, locale: "lt" },
149 { c: "\u0130", opType: 2, locale: "en" },
150 ];
151
152 for (var {c, opType, locale} of invalidValues) {
153 var s = c.repeat(1<<27);
154 switch (opType) {
155 case 0:
156 assertThrows(() => s.toUpperCase(), RangeError);
157 break;
158 case 1:
159 assertThrows(() => s.toLocaleUpperCase(locale), RangeError);
160 break;
161 case 2:
162 assertThrows(() => s.toLocaleLowerCase(locale), RangeError);
163 break;
164 }
165 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698