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

Unified 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: add tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/intl/general/case-mapping.js
diff --git a/test/intl/general/case-mapping.js b/test/intl/general/case-mapping.js
index a73622bf0deb9cfdf35ae0071737bb5c633cbeb8..548f6e95b7988a7b8a4ba3df1af6866cc8b2ccfe 100644
--- a/test/intl/general/case-mapping.js
+++ b/test/intl/general/case-mapping.js
@@ -136,3 +136,38 @@ assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase());
assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"]));
assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"]));
assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase());
+
+// If the result of case mapping is longer than the max string length
+// (1<<28 - 16), it should throw a range error instead of crashing.
+var invalidValues = [
+ { s: "\u0390", opType: 0 },
+ { s: "ß", opType: 0 },
+ { s: "\uFB01", opType: 0 }, // fi ligature
+ { s: "\uFB04", opType: 0 }, // ffl ligature
+ { s: "\u0390", opType: 1, locale: "und" },
+ { s: "\u00CC", opType: 2, locale: "lt" },
+ { s: "\u0130", opType: 2, locale: "en" },
+];
+
+invalidValues.forEach(function(value) {
Dan Ehrenberg 2016/08/10 19:06:23 Wouldn't this be a great place to use destructurin
+ var error;
+ try {
+ var s = value.s.repeat(1<<27);
+ switch (value.opType) {
+ case 0:
+ s.toUpperCase();
+ break;
+ case 1:
+ s.toLocaleUpperCase(value.locale);
+ break;
+ case 2:
+ s.toLocaleLowerCase(value.locale);
+ break;
+ }
+ } catch (e) {
+ error = e;
+ }
+
+ assertTrue(error !== undefined);
+ assertEquals('RangeError', error.name);
Dan Ehrenberg 2016/08/10 19:08:02 You could also do assertThrows(() => s.toLocaleUpp
+});
« 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