Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --harmony-strings | |
| 6 | |
| 7 function toSurrogatePair(c) { | |
| 8 return String.fromCharCode(((c - 0x10000) >>> 10) & 0x3FF | 0xD800) + | |
| 9 String.fromCharCode(c & 0x3FF | 0xDC00); | |
|
mathias
2014/10/09 14:45:42
Since `--harmony-strings` is set anyway, why not u
Yang
2014/10/09 14:50:18
Apparently flags are not parsed in intl/ tests. I'
| |
| 10 } | |
| 11 | |
| 12 function testIdStart(c, is_id_start) { | |
| 13 var source = "var " + toSurrogatePair(c); | |
| 14 print(source); | |
| 15 if (is_id_start) { | |
| 16 assertDoesNotThrow(source); | |
| 17 } else { | |
| 18 assertThrows(source); | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 function testIdPart(c, is_id_start) { | |
| 23 var source = "var v" + toSurrogatePair(c); | |
| 24 print(source); | |
| 25 if (is_id_start) { | |
| 26 assertDoesNotThrow(source); | |
| 27 } else { | |
| 28 assertThrows(source); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 [0x10403, 0x1043C, 0x16F9C, 0x10048, 0x1014D].forEach(function(c) { | |
| 33 testIdStart(c, true); | |
| 34 testIdPart(c, true); | |
| 35 }); | |
| 36 | |
| 37 [0x101FD, 0x11002, 0x104A9].forEach(function(c) { | |
| 38 testIdStart(c, false); | |
| 39 testIdPart(c, true); | |
| 40 }); | |
| 41 | |
| 42 [0x10111, 0x1F4A9].forEach(function(c) { | |
| 43 testIdStart(c, false); | |
| 44 testIdPart(c, false); | |
| 45 }); | |
| OLD | NEW |