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

Side by Side Diff: test/cctest/test-regexp.cc

Issue 13784: * Fixed bug in handling of quantified look-aheads. (Closed)
Patch Set: Created 12 years 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
« src/parser.cc ('K') | « src/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 ZoneScope zone_scope(DELETE_ON_EXIT); 56 ZoneScope zone_scope(DELETE_ON_EXIT);
57 FlatStringReader reader(CStrVector(input)); 57 FlatStringReader reader(CStrVector(input));
58 RegExpCompileData result; 58 RegExpCompileData result;
59 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 59 CHECK(v8::internal::ParseRegExp(&reader, false, &result));
60 CHECK(result.tree != NULL); 60 CHECK(result.tree != NULL);
61 CHECK(result.error.is_null()); 61 CHECK(result.error.is_null());
62 SmartPointer<const char> output = result.tree->ToString(); 62 SmartPointer<const char> output = result.tree->ToString();
63 return output; 63 return output;
64 } 64 }
65 65
66 static bool ParseEscapes(const char* input) { 66 static bool CheckNonSimple(const char* input) {
67 V8::Initialize(NULL); 67 V8::Initialize(NULL);
68 v8::HandleScope scope; 68 v8::HandleScope scope;
69 unibrow::Utf8InputBuffer<> buffer(input, strlen(input)); 69 unibrow::Utf8InputBuffer<> buffer(input, strlen(input));
70 ZoneScope zone_scope(DELETE_ON_EXIT); 70 ZoneScope zone_scope(DELETE_ON_EXIT);
71 FlatStringReader reader(CStrVector(input)); 71 FlatStringReader reader(CStrVector(input));
72 RegExpCompileData result; 72 RegExpCompileData result;
73 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 73 CHECK(v8::internal::ParseRegExp(&reader, false, &result));
74 CHECK(result.tree != NULL); 74 CHECK(result.tree != NULL);
75 CHECK(result.error.is_null()); 75 CHECK(result.error.is_null());
76 return result.has_character_escapes; 76 return !result.tree->IsAtom() || result.non_simple;
77 } 77 }
78 78
79 79
80 #define CHECK_PARSE_EQ(input, expected) CHECK_EQ(expected, *Parse(input)) 80 #define CHECK_PARSE_EQ(input, expected) CHECK_EQ(expected, *Parse(input))
81 #define CHECK_ESCAPES(input, has_escapes) CHECK_EQ(has_escapes, \ 81 #define CHECK_NON_SIMPLE(input, non_simple) CHECK_EQ(non_simple, \
82 ParseEscapes(input)); 82 CheckNonSimple(input));
83 83
84 TEST(Parser) { 84 TEST(Parser) {
85 V8::Initialize(NULL); 85 V8::Initialize(NULL);
86 CHECK_PARSE_EQ("abc", "'abc'"); 86 CHECK_PARSE_EQ("abc", "'abc'");
87 CHECK_PARSE_EQ("", "%"); 87 CHECK_PARSE_EQ("", "%");
88 CHECK_PARSE_EQ("abc|def", "(| 'abc' 'def')"); 88 CHECK_PARSE_EQ("abc|def", "(| 'abc' 'def')");
89 CHECK_PARSE_EQ("abc|def|ghi", "(| 'abc' 'def' 'ghi')"); 89 CHECK_PARSE_EQ("abc|def|ghi", "(| 'abc' 'def' 'ghi')");
90 CHECK_PARSE_EQ("^xxx$", "(: @^i 'xxx' @$i)"); 90 CHECK_PARSE_EQ("^xxx$", "(: @^i 'xxx' @$i)");
91 CHECK_PARSE_EQ("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')"); 91 CHECK_PARSE_EQ("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')");
92 CHECK_PARSE_EQ("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])"); 92 CHECK_PARSE_EQ("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])");
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 CHECK_PARSE_EQ("[\\118]", "[\\x09 8]"); 179 CHECK_PARSE_EQ("[\\118]", "[\\x09 8]");
180 CHECK_PARSE_EQ("[\\111]", "[I]"); 180 CHECK_PARSE_EQ("[\\111]", "[I]");
181 CHECK_PARSE_EQ("[\\1111]", "[I 1]"); 181 CHECK_PARSE_EQ("[\\1111]", "[I 1]");
182 CHECK_PARSE_EQ("\\x34", "'\x34'"); 182 CHECK_PARSE_EQ("\\x34", "'\x34'");
183 CHECK_PARSE_EQ("\\x60", "'\x60'"); 183 CHECK_PARSE_EQ("\\x60", "'\x60'");
184 CHECK_PARSE_EQ("\\x3z", "'x3z'"); 184 CHECK_PARSE_EQ("\\x3z", "'x3z'");
185 CHECK_PARSE_EQ("\\u0034", "'\x34'"); 185 CHECK_PARSE_EQ("\\u0034", "'\x34'");
186 CHECK_PARSE_EQ("\\u003z", "'u003z'"); 186 CHECK_PARSE_EQ("\\u003z", "'u003z'");
187 CHECK_PARSE_EQ("foo[z]*", "(: 'foo' (# 0 - g [z]))"); 187 CHECK_PARSE_EQ("foo[z]*", "(: 'foo' (# 0 - g [z]))");
188 188
189 CHECK_ESCAPES("a", false); 189 CHECK_NON_SIMPLE("a", false);
190 CHECK_ESCAPES("a|b", false); 190 CHECK_NON_SIMPLE("a|b", true);
191 CHECK_ESCAPES("a\\n", true); 191 CHECK_NON_SIMPLE("a\\n", true);
192 CHECK_ESCAPES("^a", false); 192 CHECK_NON_SIMPLE("^a", true);
193 CHECK_ESCAPES("a$", false); 193 CHECK_NON_SIMPLE("a$", true);
194 CHECK_ESCAPES("a\\b!", false); 194 CHECK_NON_SIMPLE("a\\b!", true);
195 CHECK_ESCAPES("a\\Bb", false); 195 CHECK_NON_SIMPLE("a\\Bb", true);
196 CHECK_ESCAPES("a*", false); 196 CHECK_NON_SIMPLE("a*", true);
197 CHECK_ESCAPES("a*?", false); 197 CHECK_NON_SIMPLE("a*?", true);
198 CHECK_ESCAPES("a?", false); 198 CHECK_NON_SIMPLE("a?", true);
199 CHECK_ESCAPES("a??", false); 199 CHECK_NON_SIMPLE("a??", true);
200 CHECK_ESCAPES("a{0,1}?", false); 200 CHECK_NON_SIMPLE("a{0,1}?", true);
201 CHECK_ESCAPES("a{1,1}?", false); 201 CHECK_NON_SIMPLE("a{1,1}?", true);
202 CHECK_ESCAPES("a{1,2}?", false); 202 CHECK_NON_SIMPLE("a{1,2}?", true);
203 CHECK_ESCAPES("a+?", false); 203 CHECK_NON_SIMPLE("a+?", true);
204 CHECK_ESCAPES("(a)", false); 204 CHECK_NON_SIMPLE("(a)", true);
205 CHECK_ESCAPES("(a)\\1", false); 205 CHECK_NON_SIMPLE("(a)\\1", true);
206 CHECK_ESCAPES("(\\1a)", false); 206 CHECK_NON_SIMPLE("(\\1a)", true);
207 CHECK_ESCAPES("\\1(a)", false); 207 CHECK_NON_SIMPLE("\\1(a)", true);
208 CHECK_ESCAPES("a\\s", false); 208 CHECK_NON_SIMPLE("a\\s", true);
209 CHECK_ESCAPES("a\\S", false); 209 CHECK_NON_SIMPLE("a\\S", true);
210 CHECK_ESCAPES("a\\d", false); 210 CHECK_NON_SIMPLE("a\\d", true);
211 CHECK_ESCAPES("a\\D", false); 211 CHECK_NON_SIMPLE("a\\D", true);
212 CHECK_ESCAPES("a\\w", false); 212 CHECK_NON_SIMPLE("a\\w", true);
213 CHECK_ESCAPES("a\\W", false); 213 CHECK_NON_SIMPLE("a\\W", true);
214 CHECK_ESCAPES("a.", false); 214 CHECK_NON_SIMPLE("a.", true);
215 CHECK_ESCAPES("a\\q", true); 215 CHECK_NON_SIMPLE("a\\q", true);
216 CHECK_ESCAPES("a[a]", false); 216 CHECK_NON_SIMPLE("a[a]", true);
217 CHECK_ESCAPES("a[^a]", false); 217 CHECK_NON_SIMPLE("a[^a]", true);
218 CHECK_ESCAPES("a[a-z]", false); 218 CHECK_NON_SIMPLE("a[a-z]", true);
219 CHECK_ESCAPES("a[\\q]", false); 219 CHECK_NON_SIMPLE("a[\\q]", true);
220 CHECK_ESCAPES("a(?:b)", false); 220 CHECK_NON_SIMPLE("a(?:b)", true);
221 CHECK_ESCAPES("a(?=b)", false); 221 CHECK_NON_SIMPLE("a(?=b)", true);
222 CHECK_ESCAPES("a(?!b)", false); 222 CHECK_NON_SIMPLE("a(?!b)", true);
223 CHECK_ESCAPES("\\x60", true); 223 CHECK_NON_SIMPLE("\\x60", true);
224 CHECK_ESCAPES("\\u0060", true); 224 CHECK_NON_SIMPLE("\\u0060", true);
225 CHECK_ESCAPES("\\cA", true); 225 CHECK_NON_SIMPLE("\\cA", true);
226 CHECK_ESCAPES("\\q", true); 226 CHECK_NON_SIMPLE("\\q", true);
227 CHECK_ESCAPES("\\1112", true); 227 CHECK_NON_SIMPLE("\\1112", true);
228 CHECK_ESCAPES("\\0", true); 228 CHECK_NON_SIMPLE("\\0", true);
229 CHECK_ESCAPES("(a)\\1", false); 229 CHECK_NON_SIMPLE("(a)\\1", true);
230 230
231 CHECK_PARSE_EQ("a{}", "'a{}'"); 231 CHECK_PARSE_EQ("a{}", "'a{}'");
232 CHECK_PARSE_EQ("a{,}", "'a{,}'"); 232 CHECK_PARSE_EQ("a{,}", "'a{,}'");
233 CHECK_PARSE_EQ("a{", "'a{'"); 233 CHECK_PARSE_EQ("a{", "'a{'");
234 CHECK_PARSE_EQ("a{z}", "'a{z}'"); 234 CHECK_PARSE_EQ("a{z}", "'a{z}'");
235 CHECK_PARSE_EQ("a{1z}", "'a{1z}'"); 235 CHECK_PARSE_EQ("a{1z}", "'a{1z}'");
236 CHECK_PARSE_EQ("a{12z}", "'a{12z}'"); 236 CHECK_PARSE_EQ("a{12z}", "'a{12z}'");
237 CHECK_PARSE_EQ("a{12,", "'a{12,'"); 237 CHECK_PARSE_EQ("a{12,", "'a{12,'");
238 CHECK_PARSE_EQ("a{12,3b", "'a{12,3b'"); 238 CHECK_PARSE_EQ("a{12,3b", "'a{12,3b'");
239 CHECK_PARSE_EQ("{}", "'{}'"); 239 CHECK_PARSE_EQ("{}", "'{}'");
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 CHECK(!InClass(i, excluded)); 1287 CHECK(!InClass(i, excluded));
1288 } 1288 }
1289 } 1289 }
1290 } 1290 }
1291 1291
1292 1292
1293 TEST(Graph) { 1293 TEST(Graph) {
1294 V8::Initialize(NULL); 1294 V8::Initialize(NULL);
1295 Execute("\\bboy\\b", false, true, true); 1295 Execute("\\bboy\\b", false, true, true);
1296 } 1296 }
OLDNEW
« src/parser.cc ('K') | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698