0dd69ec439
ES5.1 section 6 ("Source Text"): "Throughout the rest of this document, the phrase “code unit” and the word “character” will be used to refer to a 16-bit unsigned value used to represent a single 16-bit unit of text." This changed in ES6 draft section 10.1 ("Source Text"): "The ECMAScript code is expressed using Unicode, version 5.1 or later. ECMAScript source text is a sequence of code points. All Unicode code point values from U+0000 to U+10FFFF, including surrogate code points, may occur in source text where permitted by the ECMAScript grammars." This patch is to reflect this spec change. BUG=v8:3617 LOG=Y R=jochen@chromium.org Review URL: https://codereview.chromium.org/640193002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24510 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
function toSurrogatePair(c) {
|
|
return String.fromCharCode(((c - 0x10000) >>> 10) & 0x3FF | 0xD800) +
|
|
String.fromCharCode(c & 0x3FF | 0xDC00);
|
|
}
|
|
|
|
function testIdStart(c, is_id_start) {
|
|
var source = "var " + toSurrogatePair(c);
|
|
print(source);
|
|
if (is_id_start) {
|
|
assertDoesNotThrow(source);
|
|
} else {
|
|
assertThrows(source);
|
|
}
|
|
}
|
|
|
|
function testIdPart(c, is_id_start) {
|
|
var source = "var v" + toSurrogatePair(c);
|
|
print(source);
|
|
if (is_id_start) {
|
|
assertDoesNotThrow(source);
|
|
} else {
|
|
assertThrows(source);
|
|
}
|
|
}
|
|
|
|
[0x10403, 0x1043C, 0x16F9C, 0x10048, 0x1014D].forEach(function(c) {
|
|
testIdStart(c, true);
|
|
testIdPart(c, true);
|
|
});
|
|
|
|
[0x101FD, 0x11002, 0x104A9].forEach(function(c) {
|
|
testIdStart(c, false);
|
|
testIdPart(c, true);
|
|
});
|
|
|
|
[0x10111, 0x1F4A9].forEach(function(c) {
|
|
testIdStart(c, false);
|
|
testIdPart(c, false);
|
|
});
|