OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-regexp-property | 5 // Flags: --harmony-regexp-property |
6 | 6 |
7 function t(re, s) { assertTrue(re.test(s)); } | 7 function t(re, s) { assertTrue(re.test(s)); } |
8 function f(re, s) { assertFalse(re.test(s)); } | 8 function f(re, s) { assertFalse(re.test(s)); } |
9 | 9 |
10 t(/\p{Bidi_Control}+/u, "\u200E"); | |
11 f(/\p{Bidi_C}+/u, "On a dark desert highway, cool wind in my hair"); | |
12 t(/\p{AHex}+/u, "DEADBEEF"); | |
13 t(/\p{Alphabetic}+/u, "abcdefg"); | |
14 t(/\P{Alphabetic}+/u, "1234"); | |
15 t(/\p{White_Space}+/u, "\u00A0"); | |
16 t(/\p{Uppercase}+/u, "V"); | |
17 f(/\p{Lower}+/u, "U"); | |
18 t(/\p{Ideo}+/u, "字"); | |
19 f(/\p{Ideo}+/u, "x"); | |
20 t(/\p{Noncharacter_Code_Point}+/u, "\uFDD0"); | |
21 t(/\p{Default_Ignorable_Code_Point}+/u, "\u00AD"); | |
22 t(/\p{ASCII}+/u, "a"); | |
23 f(/\p{ASCII}+/u, "äöü"); | |
24 t(/\p{ID_Start}+/u, "a"); | |
25 f(/\p{ID_Start}+/u, "1\\"); | |
26 t(/\p{ID_Continue}+/u, "1"); | |
27 f(/\p{ID_Continue}+/u, "%\\"); | |
28 t(/\p{Join_Control}+/u, "\u200c"); | |
29 f(/\p{Join_Control}+/u, "a1"); | |
30 t(/\p{Emoji_Presentation}+/u, "\u{1F308}"); | |
31 f(/\p{Emoji_Presentation}+/u, "x"); | |
32 t(/\p{Emoji_Modifier}+/u, "\u{1F3FE}"); | |
33 f(/\p{Emoji_Modifier}+/u, "x"); | |
34 t(/\p{Emoji_Modifier_Base}+/u, "\u{1F6CC}"); | |
35 f(/\p{Emoji_Modifier_Base}+/u, "x"); | |
36 | |
37 assertThrows("/\\p{Hiragana}/u"); | 10 assertThrows("/\\p{Hiragana}/u"); |
38 assertThrows("/\\p{Bidi_Class}/u"); | 11 assertThrows("/\\p{Bidi_Class}/u"); |
39 assertThrows("/\\p{Bidi_C=False}/u"); | 12 assertThrows("/\\p{Bidi_C=False}/u"); |
40 assertThrows("/\\P{Bidi_Control=Y}/u"); | 13 assertThrows("/\\P{Bidi_Control=Y}/u"); |
41 assertThrows("/\\p{AHex=Yes}/u"); | 14 assertThrows("/\\p{AHex=Yes}/u"); |
15 | |
16 t(/\p{Alphabetic}/u, "æ"); | |
17 f(/\p{Alpha}/u, "1"); | |
18 | |
19 t(/\p{ASCII_Hex_Digit}/u, "f"); | |
20 f(/\p{AHex}/u, "g"); | |
21 | |
22 t(/\p{Bidi_Control}/u, "\u200e"); | |
23 f(/\p{Bidi_C}/u, "g"); | |
24 | |
25 t(/\p{Bidi_Mirrored}/u, "("); | |
26 f(/\p{Bidi_M}/u, "-"); | |
27 | |
28 t(/\p{Case_Ignorable}/u, "\u02b0"); | |
29 f(/\p{CI}/u, "a"); | |
30 | |
31 t(/\p{Changes_When_Casefolded}/u, "B"); | |
32 f(/\p{CWCF}/u, "1"); | |
33 | |
34 t(/\p{Changes_When_Casemapped}/u, "b"); | |
35 f(/\p{CWCM}/u, "1"); | |
36 | |
37 t(/\p{Changes_When_Lowercased}/u, "B"); | |
38 f(/\p{CWL}/u, "1"); | |
39 | |
40 t(/\p{Changes_When_Titlecased}/u, "b"); | |
41 f(/\p{CWT}/u, "1"); | |
42 | |
43 t(/\p{Changes_When_Uppercased}/u, "b"); | |
44 f(/\p{CWU}/u, "1"); | |
45 | |
46 //t(/\p{Composition_Exclusion}/u, "\u0958"); | |
47 //f(/\p{CE}/u, "1"); | |
mathias
2017/04/11 13:07:44
From http://unicode.org/reports/tr44/#Decompositio
| |
48 | |
49 t(/\p{Dash}/u, "-"); | |
50 f(/\p{Dash}/u, "1"); | |
51 | |
52 t(/\p{Default_Ignorable_Code_Point}/u, "\u00ad"); | |
53 f(/\p{DI}/u, "1"); | |
54 | |
55 t(/\p{Deprecated}/u, "\u17a3"); | |
56 f(/\p{Dep}/u, "1"); | |
57 | |
58 t(/\p{Diacritic}/u, "\u0301"); | |
59 f(/\p{Dia}/u, "1"); | |
60 | |
61 t(/\p{Emoji}/u, "\u2603"); | |
62 f(/\p{Emoji}/u, "x"); | |
63 | |
64 // t(/\p{Emoji_Component}/u, "\u2603"); | |
65 // f(/\p{Emoji_Component}/u, "x"); | |
mathias
2017/04/11 13:07:44
It makes sense for ICU not to support `Emoji_Compo
| |
66 | |
67 t(/\p{Emoji_Modifier_Base}/u, "\u{1F6CC}"); | |
68 f(/\p{Emoji_Modifier_Base}/u, "x"); | |
69 | |
70 t(/\p{Emoji_Modifier}/u, "\u{1F3FE}"); | |
71 f(/\p{Emoji_Modifier}/u, "x"); | |
72 | |
73 t(/\p{Emoji_Presentation}/u, "\u{1F308}"); | |
74 f(/\p{Emoji_Presentation}/u, "x"); | |
75 | |
76 t(/\p{Extender}/u, "\u3005"); | |
77 f(/\p{Ext}/u, "x"); | |
78 | |
79 t(/\p{Full_Composition_Exclusion}/u, "\uFB1F"); | |
80 f(/\p{Comp_Ex}/u, "x"); | |
81 | |
82 t(/\p{Grapheme_Base}/u, " "); | |
83 f(/\p{Gr_Base}/u, "\u0010"); | |
84 | |
85 t(/\p{Grapheme_Extend}/u, "\u0300"); | |
86 f(/\p{Gr_Ext}/u, "x"); | |
87 | |
88 t(/\p{Hex_Digit}/u, "a"); | |
89 f(/\p{Hex}/u, "g"); | |
90 | |
91 t(/\p{ID_Continue}/u, "1"); | |
92 f(/\p{IDC}/u, "."); | |
93 | |
94 t(/\p{ID_Start}/u, "a"); | |
95 f(/\p{IDS}/u, "1"); | |
96 | |
97 t(/\p{Ideographic}/u, "漢"); | |
98 f(/\p{Ideo}/u, "H"); | |
99 | |
100 t(/\p{IDS_Binary_Operator}/u, "\u2FF0"); | |
101 f(/\p{IDSB}/u, "a"); | |
102 | |
103 t(/\p{IDS_Trinary_Operator}/u, "\u2FF2"); | |
104 f(/\p{IDST}/u, "a"); | |
105 | |
106 t(/\p{Join_Control}/u, "\u200c"); | |
107 f(/\p{Join_C}/u, "a"); | |
108 | |
109 t(/\p{Logical_Order_Exception}/u, "\u0e40"); | |
110 f(/\p{LOE}/u, "a"); | |
111 | |
112 t(/\p{Lowercase}/u, "a"); | |
113 f(/\p{Lower}/u, "A"); | |
114 | |
115 t(/\p{Math}/u, "="); | |
116 f(/\p{Math}/u, "A"); | |
117 | |
118 t(/\p{Noncharacter_Code_Point}/u, "\uFDD0"); | |
119 f(/\p{NChar}/u, "A"); | |
120 | |
121 t(/\p{Pattern_Syntax}/u, "\u0021"); | |
122 f(/\p{NChar}/u, "A"); | |
123 | |
124 t(/\p{Pattern_White_Space}/u, "\u0009"); | |
125 f(/\p{Pat_Syn}/u, "A"); | |
126 | |
127 // t(/\p{Prepended_Concatenation_Mark}/u, "\uFDD0"); | |
128 // f(/\p{PCM}/u, "A"); | |
mathias
2017/04/11 13:07:44
I can’t think of a reason for ICU not to support t
| |
129 | |
130 t(/\p{Quotation_Mark}/u, "'"); | |
131 f(/\p{QMark}/u, "A"); | |
132 | |
133 t(/\p{Radical}/u, "\u2FAD"); | |
134 f(/\p{Radical}/u, "A"); | |
135 | |
136 t(/\p{Sentence_Terminal}/u, "!"); | |
137 f(/\p{STerm}/u, "A"); | |
138 | |
139 t(/\p{Soft_Dotted}/u, "i"); | |
140 f(/\p{SD}/u, "A"); | |
141 | |
142 t(/\p{Terminal_Punctuation}/u, "."); | |
143 f(/\p{Term}/u, "A"); | |
144 | |
145 t(/\p{Unified_Ideograph}/u, "\u4e00"); | |
146 f(/\p{UIdeo}/u, "A"); | |
147 | |
148 t(/\p{Uppercase}/u, "A"); | |
149 f(/\p{Upper}/u, "a"); | |
150 | |
151 t(/\p{Variation_Selector}/u, "\uFE00"); | |
152 f(/\p{VS}/u, "A"); | |
153 | |
154 t(/\p{White_Space}/u, " "); | |
155 f(/\p{WSpace}/u, "A"); | |
156 | |
157 t(/\p{XID_Continue}/u, "1"); | |
158 f(/\p{XIDC}/u, " "); | |
159 | |
160 t(/\p{XID_Start}/u, "A"); | |
161 f(/\p{XIDS}/u, " "); | |
OLD | NEW |