Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Side by Side Diff: test/mjsunit/harmony/unicode-character-ranges.js

Issue 2096933002: Remove all harmony runtime flags which shipped in M51 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-unicode-regexps --harmony-regexp-lookbehind
6
7 function execl(expectation, regexp, subject) {
8 if (regexp instanceof String) regexp = new RegExp(regexp, "u");
9 assertEquals(expectation, regexp.exec(subject));
10 }
11
12 function execs(expectation, regexp_source, subject) {
13 execl(expectation, new RegExp(regexp_source, "u"), subject);
14 }
15
16 // Character ranges.
17 execl(["A"], /[A-D]/u, "A");
18 execs(["A"], "[A-D]", "A");
19 execl(["ABCD"], /[A-D]+/u, "ZABCDEF");
20 execs(["ABCD"], "[A-D]+", "ZABCDEF");
21
22 execl(["\u{12345}"], /[\u1234-\u{12345}]/u, "\u{12345}");
23 execs(["\u{12345}"], "[\u1234-\u{12345}]", "\u{12345}");
24 execl(null, /[^\u1234-\u{12345}]/u, "\u{12345}");
25 execs(null, "[^\u1234-\u{12345}]", "\u{12345}");
26
27 execl(["\u{1234}"], /[\u1234-\u{12345}]/u, "\u{1234}");
28 execs(["\u{1234}"], "[\u1234-\u{12345}]", "\u{1234}");
29 execl(null, /[^\u1234-\u{12345}]/u, "\u{1234}");
30 execs(null, "[^\u1234-\u{12345}]", "\u{1234}");
31
32 execl(null, /[\u1234-\u{12345}]/u, "\u{1233}");
33 execs(null, "[\u1234-\u{12345}]", "\u{1233}");
34 execl(["\u{1233}"], /[^\u1234-\u{12345}]/u, "\u{1233}");
35 execs(["\u{1233}"], "[^\u1234-\u{12345}]", "\u{1233}");
36
37 execl(["\u{12346}"], /[^\u1234-\u{12345}]/u, "\u{12346}");
38 execs(["\u{12346}"], "[^\u1234-\u{12345}]", "\u{12346}");
39 execl(null, /[\u1234-\u{12345}]/u, "\u{12346}");
40 execs(null, "[\u1234-\u{12345}]", "\u{12346}");
41
42 execl(["\u{12342}"], /[\u{12340}-\u{12345}]/u, "\u{12342}");
43 execs(["\u{12342}"], "[\u{12340}-\u{12345}]", "\u{12342}");
44 execl(["\u{12342}"], /[\ud808\udf40-\ud808\udf45]/u, "\u{12342}");
45 execs(["\u{12342}"], "[\ud808\udf40-\ud808\udf45]", "\u{12342}");
46 execl(null, /[^\u{12340}-\u{12345}]/u, "\u{12342}");
47 execs(null, "[^\u{12340}-\u{12345}]", "\u{12342}");
48 execl(null, /[^\ud808\udf40-\ud808\udf45]/u, "\u{12342}");
49 execs(null, "[^\ud808\udf40-\ud808\udf45]", "\u{12342}");
50
51 execl(["\u{ffff}"], /[\u{ff80}-\u{12345}]/u, "\u{ffff}");
52 execs(["\u{ffff}"], "[\u{ff80}-\u{12345}]", "\u{ffff}");
53 execl(["\u{ffff}"], /[\u{ff80}-\ud808\udf45]/u, "\u{ffff}");
54 execs(["\u{ffff}"], "[\u{ff80}-\ud808\udf45]", "\u{ffff}");
55 execl(null, /[^\u{ff80}-\u{12345}]/u, "\u{ffff}");
56 execs(null, "[^\u{ff80}-\u{12345}]", "\u{ffff}");
57 execl(null, /[^\u{ff80}-\ud808\udf45]/u, "\u{ffff}");
58 execs(null, "[^\u{ff80}-\ud808\udf45]", "\u{ffff}");
59
60 // Lone surrogate
61 execl(["\ud800"], /[^\u{ff80}-\u{12345}]/u, "\uff99\u{d800}A");
62 execs(["\udc00"], "[^\u{ff80}-\u{12345}]", "\uff99\u{dc00}A");
63 execl(["\udc01"], /[\u0100-\u{10ffff}]/u, "A\udc01");
64 execl(["\udc03"], /[\udc01-\udc03]/u, "\ud801\udc02\udc03");
65 execl(["\ud801"], /[\ud801-\ud803]/u, "\ud802\udc01\ud801");
66
67 // Paired sorrogate.
68 execl(null, /[^\u{ff80}-\u{12345}]/u, "\u{d800}\u{dc00}");
69 execs(null, "[^\u{ff80}-\u{12345}]", "\u{d800}\u{dc00}");
70 execl(["\ud800\udc00"], /[\u{ff80}-\u{12345}]/u, "\u{d800}\u{dc00}");
71 execs(["\ud800\udc00"], "[\u{ff80}-\u{12345}]", "\u{d800}\u{dc00}");
72 execl(["foo\u{10e6d}bar"], /foo\ud803\ude6dbar/u, "foo\u{10e6d}bar");
73
74 // Lone surrogates
75 execl(["\ud801\ud801"], /\ud801+/u, "\ud801\udc01\ud801\ud801");
76 execl(["\udc01\udc01"], /\udc01+/u, "\ud801\ud801\udc01\udc01\udc01");
77
78 execl(["\udc02\udc03A"], /\W\WA/u, "\ud801\udc01A\udc02\udc03A");
79 execl(["\ud801\ud802"], /\ud801./u, "\ud801\udc01\ud801\ud802");
80 execl(["\udc02\udc03A"], /[\ud800-\udfff][\ud800-\udfff]A/u,
81 "\ud801\udc01A\udc02\udc03A");
82
83 // Character classes
84 execl(null, /\w/u, "\ud801\udc01");
85 execl(["\ud801"], /[^\w]/, "\ud801\udc01");
86 execl(["\ud801\udc01"], /[^\w]/u, "\ud801\udc01");
87 execl(["\ud801"], /\W/, "\ud801\udc01");
88 execl(["\ud801\udc01"], /\W/u, "\ud801\udc01");
89
90 execl(["\ud800X"], /.X/u, "\ud800XaX");
91 execl(["aX"], /.(?<!\ud800)X/u, "\ud800XaX");
92 execl(["aX"], /.(?<![\ud800-\ud900])X/u, "\ud800XaX");
93
94 execl(null, /[]/u, "\u1234");
95 execl(["0abc"], /[^]abc/u, "0abc");
96 execl(["\u1234abc"], /[^]abc/u, "\u1234abc");
97 execl(["\u{12345}abc"], /[^]abc/u, "\u{12345}abc");
98
99 execl(null, /[\u{0}-\u{1F444}]/u, "\ud83d\udfff");
100
101 // Backward matches of lone surrogates.
102 execl(["B", "\ud803A"], /(?<=([\ud800-\ud900]A))B/u,
103 "\ud801\udc00AB\udc00AB\ud802\ud803AB");
104 execl(["B", "\udc00A"], /(?<=([\ud800-\u{10300}]A))B/u,
105 "\ud801\udc00AB\udc00AB\ud802\ud803AB");
106 execl(["B", "\udc11A"], /(?<=([\udc00-\udd00]A))B/u,
107 "\ud801\udc00AB\udc11AB\ud802\ud803AB");
108 execl(["X", "\ud800C"], /(?<=(\ud800\w))X/u,
109 "\ud800\udc00AX\udc11BX\ud800\ud800CX");
110 execl(["C", "\ud800\ud800"], /(?<=(\ud800.))\w/u,
111 "\ud800\udc00AX\udc11BX\ud800\ud800CX");
112 execl(["X", "\udc01C"], /(?<=(\udc01\w))X/u,
113 "\ud800\udc01AX\udc11BX\udc01\udc01CX");
114 execl(["C", "\udc01\udc01"], /(?<=(\udc01.))./u,
115 "\ud800\udc01AX\udc11BX\udc01\udc01CX");
116
117 var L = "\ud800";
118 var T = "\udc00";
119 var X = "X";
120
121 // Test string contains only match.
122 function testw(expect, src, subject) {
123 var re = new RegExp("^" + src + "$", "u");
124 assertEquals(expect, re.test(subject));
125 }
126
127 // Test string starts with match.
128 function tests(expect, src, subject) {
129 var re = new RegExp("^" + src, "u");
130 assertEquals(expect, re.test(subject));
131 }
132
133 testw(true, X, X);
134 testw(true, L, L);
135 testw(true, T, T);
136 testw(true, L + T, L + T);
137 testw(true, T + L, T + L);
138 testw(false, T, L + T);
139 testw(false, L, L + T);
140 testw(true, ".(?<=" + L + ")", L);
141 testw(true, ".(?<=" + T + ")", T);
142 testw(true, ".(?<=" + L + T + ")", L + T);
143 testw(true, ".(?<=" + L + T + ")", L + T);
144 tests(true, ".(?<=" + T + ")", T + L);
145 tests(false, ".(?<=" + L + ")", L + T);
146 tests(false, ".(?<=" + T + ")", L + T);
147 tests(true, "..(?<=" + T + ")", T + T + L);
148 tests(true, "..(?<=" + T + ")", X + T + L);
149 tests(true, "...(?<=" + L + ")", X + T + L);
150 tests(false, "...(?<=" + T + ")", X + L + T)
151 tests(true, "..(?<=" + L + T + ")", X + L + T)
152 tests(true, "..(?<=" + L + T + "(?<=" + L + T + "))", X + L + T);
153 tests(false, "..(?<=" + L + "(" + T + "))", X + L + T);
154 tests(false, ".*" + L, X + L + T);
155 tests(true, ".*" + L, X + L + L + T);
156 tests(false, ".*" + L, X + L + T + L + T);
157 tests(false, ".*" + T, X + L + T + L + T);
158 tests(true, ".*" + T, X + L + T + T + L + T);
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/typedarray-species.js ('k') | test/mjsunit/harmony/unicode-escapes-in-regexps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698