mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 1556230 - Add comments and a test. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D33675 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c7296e7825
commit
a09c2fa5e0
60
js/src/tests/non262/Unicode/non-bmp-non-spaces.js
Normal file
60
js/src/tests/non262/Unicode/non-bmp-non-spaces.js
Normal file
@ -0,0 +1,60 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// White space must not be determined by truncating char32_t to char16_t.
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{40008}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{40009}"), SyntaxError); // U+0009 CHARACTER TABULATION
|
||||
assertThrowsInstanceOf(() => eval("\u{4000A}"), SyntaxError); // U+000A LINE FEED
|
||||
assertThrowsInstanceOf(() => eval("\u{4000B}"), SyntaxError); // U+000B LINE TABULATION
|
||||
assertThrowsInstanceOf(() => eval("\u{4000C}"), SyntaxError); // U+000C FORM FEED
|
||||
assertThrowsInstanceOf(() => eval("\u{4000D}"), SyntaxError); // U+000D CARRIAGE RETURN
|
||||
assertThrowsInstanceOf(() => eval("\u{4000E}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{4001F}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{40020}"), SyntaxError); // U+0020 SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{40021}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{4009F}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{400A0}"), SyntaxError); // U+00A0 NO-BREAK SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{400A1}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{4167F}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{41680}"), SyntaxError); // U+1680 OGHAM SPACE MARK
|
||||
assertThrowsInstanceOf(() => eval("\u{41681}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{41FFF}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{42000}"), SyntaxError); // U+2000 EN QUAD
|
||||
assertThrowsInstanceOf(() => eval("\u{42001}"), SyntaxError); // U+2001 EM QUAD
|
||||
assertThrowsInstanceOf(() => eval("\u{42002}"), SyntaxError); // U+2002 EN SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42003}"), SyntaxError); // U+2003 EM SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42004}"), SyntaxError); // U+2004 THREE-PER-EM SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42005}"), SyntaxError); // U+2005 FOUR-PER-EM SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42006}"), SyntaxError); // U+2006 SIX-PER-EM SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42007}"), SyntaxError); // U+2007 FIGURE SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42008}"), SyntaxError); // U+2008 PUNCTUATION SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42009}"), SyntaxError); // U+2009 THIN SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{4200A}"), SyntaxError); // U+200A HAIR SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{4200B}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{42027}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{42028}"), SyntaxError); // U+2028 LINE SEPARATOR
|
||||
assertThrowsInstanceOf(() => eval("\u{42029}"), SyntaxError); // U+2028 PARAGRAPH SEPARATOR
|
||||
assertThrowsInstanceOf(() => eval("\u{4202A}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{4202E}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{4202F}"), SyntaxError); // U+202F NARROW NO-BREAK SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42030}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{4205E}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{4205F}"), SyntaxError); // U+205F MEDIUM MATHEMATICAL SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{42060}"), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval("\u{42FFF}"), SyntaxError);
|
||||
assertThrowsInstanceOf(() => eval("\u{43000}"), SyntaxError); // U+3000 IDEOGRAPHIC SPACE
|
||||
assertThrowsInstanceOf(() => eval("\u{43001}"), SyntaxError);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
@ -7,6 +7,8 @@
|
||||
#ifndef util_Unicode_h
|
||||
#define util_Unicode_h
|
||||
|
||||
#include "mozilla/Casting.h" // mozilla::AssertedCast
|
||||
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "util/UnicodeNonBMP.h"
|
||||
@ -241,6 +243,7 @@ inline bool IsSpace(char ch) {
|
||||
return IsSpace(static_cast<JS::Latin1Char>(ch));
|
||||
}
|
||||
|
||||
// IsSpace(char32_t) must additionally exclude everything non-BMP.
|
||||
inline bool IsSpace(char32_t ch) {
|
||||
if (ch < 128) {
|
||||
return js_isspace[ch];
|
||||
@ -250,11 +253,13 @@ inline bool IsSpace(char32_t ch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// An assertion in make_unicode.py:make_unicode_file guarantees that there are
|
||||
// no Space_Separator (Zs) code points outside the BMP.
|
||||
if (ch >= NonBMPMin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CharInfo(ch).isSpace();
|
||||
return CharInfo(mozilla::AssertedCast<char16_t>(ch)).isSpace();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1255,7 +1255,8 @@ def make_unicode_file(version,
|
||||
|
||||
# If the following assert fails, it means space character is added to
|
||||
# non-BMP area. In that case the following code should be uncommented
|
||||
# and the corresponding code should be added to frontend.
|
||||
# and the corresponding code should be added to frontend. (At least
|
||||
# unicode::IsSpace will require updating to handle this.)
|
||||
assert len(non_bmp_space_set.keys()) == 0
|
||||
|
||||
write_supplemental_identifier_method('IsIdentifierStartNonBMP', non_bmp_id_start_set,
|
||||
|
Loading…
Reference in New Issue
Block a user