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 function toSurrogatePair(c) { |
| 6 return String.fromCharCode(((c - 0x10000) >>> 10) & 0x3FF | 0xD800) + |
| 7 String.fromCharCode(c & 0x3FF | 0xDC00); |
| 8 } |
| 9 |
| 10 function testIdStart(c, is_id_start) { |
| 11 var source = "var " + toSurrogatePair(c); |
| 12 print(source); |
| 13 if (is_id_start) { |
| 14 assertDoesNotThrow(source); |
| 15 } else { |
| 16 assertThrows(source); |
| 17 } |
| 18 } |
| 19 |
| 20 function testIdPart(c, is_id_start) { |
| 21 var source = "var v" + toSurrogatePair(c); |
| 22 print(source); |
| 23 if (is_id_start) { |
| 24 assertDoesNotThrow(source); |
| 25 } else { |
| 26 assertThrows(source); |
| 27 } |
| 28 } |
| 29 |
| 30 [0x10403, 0x1043C, 0x16F9C, 0x10048, 0x1014D].forEach(function(c) { |
| 31 testIdStart(c, true); |
| 32 testIdPart(c, true); |
| 33 }); |
| 34 |
| 35 [0x101FD, 0x11002, 0x104A9].forEach(function(c) { |
| 36 testIdStart(c, false); |
| 37 testIdPart(c, true); |
| 38 }); |
| 39 |
| 40 [0x10111, 0x1F4A9].forEach(function(c) { |
| 41 testIdStart(c, false); |
| 42 testIdPart(c, false); |
| 43 }); |
OLD | NEW |