Chromium Code Reviews| 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
|
| +}); |