Commit eee27925 authored by yangguo's avatar yangguo Committed by Commit bot

[regexp] Add tests for binary property classes.

See https://tc39.github.io/proposal-regexp-unicode-property-escapes

R=jgruber@chromium.org
BUG=v8:4743

Review-Url: https://codereview.chromium.org/2807293003
Cr-Commit-Position: refs/heads/master@{#44577}
parent 9679a366
......@@ -7,35 +7,155 @@
function t(re, s) { assertTrue(re.test(s)); }
function f(re, s) { assertFalse(re.test(s)); }
t(/\p{Bidi_Control}+/u, "\u200E");
f(/\p{Bidi_C}+/u, "On a dark desert highway, cool wind in my hair");
t(/\p{AHex}+/u, "DEADBEEF");
t(/\p{Alphabetic}+/u, "abcdefg");
t(/\P{Alphabetic}+/u, "1234");
t(/\p{White_Space}+/u, "\u00A0");
t(/\p{Uppercase}+/u, "V");
f(/\p{Lower}+/u, "U");
t(/\p{Ideo}+/u, "字");
f(/\p{Ideo}+/u, "x");
t(/\p{Noncharacter_Code_Point}+/u, "\uFDD0");
t(/\p{Default_Ignorable_Code_Point}+/u, "\u00AD");
t(/\p{ASCII}+/u, "a");
f(/\p{ASCII}+/u, "äöü");
t(/\p{ID_Start}+/u, "a");
f(/\p{ID_Start}+/u, "1\\");
t(/\p{ID_Continue}+/u, "1");
f(/\p{ID_Continue}+/u, "%\\");
t(/\p{Join_Control}+/u, "\u200c");
f(/\p{Join_Control}+/u, "a1");
t(/\p{Emoji_Presentation}+/u, "\u{1F308}");
f(/\p{Emoji_Presentation}+/u, "x");
t(/\p{Emoji_Modifier}+/u, "\u{1F3FE}");
f(/\p{Emoji_Modifier}+/u, "x");
t(/\p{Emoji_Modifier_Base}+/u, "\u{1F6CC}");
f(/\p{Emoji_Modifier_Base}+/u, "x");
assertThrows("/\\p{Hiragana}/u");
assertThrows("/\\p{Bidi_Class}/u");
assertThrows("/\\p{Bidi_C=False}/u");
assertThrows("/\\P{Bidi_Control=Y}/u");
assertThrows("/\\p{AHex=Yes}/u");
t(/\p{Alphabetic}/u, "æ");
f(/\p{Alpha}/u, "1");
t(/\p{ASCII_Hex_Digit}/u, "f");
f(/\p{AHex}/u, "g");
t(/\p{Bidi_Control}/u, "\u200e");
f(/\p{Bidi_C}/u, "g");
t(/\p{Bidi_Mirrored}/u, "(");
f(/\p{Bidi_M}/u, "-");
t(/\p{Case_Ignorable}/u, "\u02b0");
f(/\p{CI}/u, "a");
t(/\p{Changes_When_Casefolded}/u, "B");
f(/\p{CWCF}/u, "1");
t(/\p{Changes_When_Casemapped}/u, "b");
f(/\p{CWCM}/u, "1");
t(/\p{Changes_When_Lowercased}/u, "B");
f(/\p{CWL}/u, "1");
t(/\p{Changes_When_Titlecased}/u, "b");
f(/\p{CWT}/u, "1");
t(/\p{Changes_When_Uppercased}/u, "b");
f(/\p{CWU}/u, "1");
//t(/\p{Composition_Exclusion}/u, "\u0958");
//f(/\p{CE}/u, "1");
t(/\p{Dash}/u, "-");
f(/\p{Dash}/u, "1");
t(/\p{Default_Ignorable_Code_Point}/u, "\u00ad");
f(/\p{DI}/u, "1");
t(/\p{Deprecated}/u, "\u17a3");
f(/\p{Dep}/u, "1");
t(/\p{Diacritic}/u, "\u0301");
f(/\p{Dia}/u, "1");
t(/\p{Emoji}/u, "\u2603");
f(/\p{Emoji}/u, "x");
// t(/\p{Emoji_Component}/u, "\u2603");
// f(/\p{Emoji_Component}/u, "x");
t(/\p{Emoji_Modifier_Base}/u, "\u{1F6CC}");
f(/\p{Emoji_Modifier_Base}/u, "x");
t(/\p{Emoji_Modifier}/u, "\u{1F3FE}");
f(/\p{Emoji_Modifier}/u, "x");
t(/\p{Emoji_Presentation}/u, "\u{1F308}");
f(/\p{Emoji_Presentation}/u, "x");
t(/\p{Extender}/u, "\u3005");
f(/\p{Ext}/u, "x");
t(/\p{Full_Composition_Exclusion}/u, "\uFB1F");
f(/\p{Comp_Ex}/u, "x");
t(/\p{Grapheme_Base}/u, " ");
f(/\p{Gr_Base}/u, "\u0010");
t(/\p{Grapheme_Extend}/u, "\u0300");
f(/\p{Gr_Ext}/u, "x");
t(/\p{Hex_Digit}/u, "a");
f(/\p{Hex}/u, "g");
t(/\p{ID_Continue}/u, "1");
f(/\p{IDC}/u, ".");
t(/\p{ID_Start}/u, "a");
f(/\p{IDS}/u, "1");
t(/\p{Ideographic}/u, "漢");
f(/\p{Ideo}/u, "H");
t(/\p{IDS_Binary_Operator}/u, "\u2FF0");
f(/\p{IDSB}/u, "a");
t(/\p{IDS_Trinary_Operator}/u, "\u2FF2");
f(/\p{IDST}/u, "a");
t(/\p{Join_Control}/u, "\u200c");
f(/\p{Join_C}/u, "a");
t(/\p{Logical_Order_Exception}/u, "\u0e40");
f(/\p{LOE}/u, "a");
t(/\p{Lowercase}/u, "a");
f(/\p{Lower}/u, "A");
t(/\p{Math}/u, "=");
f(/\p{Math}/u, "A");
t(/\p{Noncharacter_Code_Point}/u, "\uFDD0");
f(/\p{NChar}/u, "A");
t(/\p{Pattern_Syntax}/u, "\u0021");
f(/\p{NChar}/u, "A");
t(/\p{Pattern_White_Space}/u, "\u0009");
f(/\p{Pat_Syn}/u, "A");
// t(/\p{Prepended_Concatenation_Mark}/u, "\uFDD0");
// f(/\p{PCM}/u, "A");
t(/\p{Quotation_Mark}/u, "'");
f(/\p{QMark}/u, "A");
t(/\p{Radical}/u, "\u2FAD");
f(/\p{Radical}/u, "A");
t(/\p{Sentence_Terminal}/u, "!");
f(/\p{STerm}/u, "A");
t(/\p{Soft_Dotted}/u, "i");
f(/\p{SD}/u, "A");
t(/\p{Terminal_Punctuation}/u, ".");
f(/\p{Term}/u, "A");
t(/\p{Unified_Ideograph}/u, "\u4e00");
f(/\p{UIdeo}/u, "A");
t(/\p{Uppercase}/u, "A");
f(/\p{Upper}/u, "a");
t(/\p{Variation_Selector}/u, "\uFE00");
f(/\p{VS}/u, "A");
t(/\p{White_Space}/u, " ");
f(/\p{WSpace}/u, "A");
t(/\p{XID_Continue}/u, "1");
f(/\p{XIDC}/u, " ");
t(/\p{XID_Start}/u, "A");
f(/\p{XIDS}/u, " ");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment