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

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

Issue 1522353002: [regexp] break recursion in mutually recursive capture/back references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: new test expectations Created 5 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
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/harmony/regexp-lookbehind.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 v8::HandleScope scope(CcTest::isolate()); 103 v8::HandleScope scope(CcTest::isolate());
104 Zone zone; 104 Zone zone;
105 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 105 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
106 RegExpCompileData result; 106 RegExpCompileData result;
107 CHECK(v8::internal::RegExpParser::ParseRegExp( 107 CHECK(v8::internal::RegExpParser::ParseRegExp(
108 CcTest::i_isolate(), &zone, &reader, false, false, &result)); 108 CcTest::i_isolate(), &zone, &reader, false, false, &result));
109 CHECK(result.tree != NULL); 109 CHECK(result.tree != NULL);
110 CHECK(result.error.is_null()); 110 CHECK(result.error.is_null());
111 std::ostringstream os; 111 std::ostringstream os;
112 result.tree->Print(os, &zone); 112 result.tree->Print(os, &zone);
113 if (strcmp(expected, os.str().c_str()) != 0) {
114 printf("%s | %s\n", expected, os.str().c_str());
115 }
113 CHECK_EQ(0, strcmp(expected, os.str().c_str())); 116 CHECK_EQ(0, strcmp(expected, os.str().c_str()));
114 } 117 }
115 118
116 119
117 static bool CheckSimple(const char* input) { 120 static bool CheckSimple(const char* input) {
118 v8::HandleScope scope(CcTest::isolate()); 121 v8::HandleScope scope(CcTest::isolate());
119 Zone zone; 122 Zone zone;
120 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 123 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
121 RegExpCompileData result; 124 RegExpCompileData result;
122 CHECK(v8::internal::RegExpParser::ParseRegExp( 125 CHECK(v8::internal::RegExpParser::ParseRegExp(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 " (# 0 - g '\\x04'))"); 265 " (# 0 - g '\\x04'))");
263 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10", 266 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10",
264 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" 267 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
265 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))"); 268 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))");
266 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11", 269 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11",
267 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" 270 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
268 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')"); 271 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')");
269 CheckParseEq("(a)\\1", "(: (^ 'a') (<- 1))"); 272 CheckParseEq("(a)\\1", "(: (^ 'a') (<- 1))");
270 CheckParseEq("(a\\1)", "(^ 'a')"); 273 CheckParseEq("(a\\1)", "(^ 'a')");
271 CheckParseEq("(\\1a)", "(^ 'a')"); 274 CheckParseEq("(\\1a)", "(^ 'a')");
275 CheckParseEq("(\\2)(\\1)", "(: (^ (<- 2)) (^ (<- 1)))");
272 CheckParseEq("(?=a)?a", "'a'"); 276 CheckParseEq("(?=a)?a", "'a'");
273 CheckParseEq("(?=a){0,10}a", "'a'"); 277 CheckParseEq("(?=a){0,10}a", "'a'");
274 CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')"); 278 CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')");
275 CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')"); 279 CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')");
276 CheckParseEq("(?!a)?a", "'a'"); 280 CheckParseEq("(?!a)?a", "'a'");
277 CheckParseEq("\\1(a)", "(: (<- 1) (^ 'a'))"); 281 CheckParseEq("\\1(a)", "(: (<- 1) (^ 'a'))");
278 CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))"); 282 CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))");
279 CheckParseEq("(?!\\1(a\\1)\\1)\\1", 283 CheckParseEq("(?!\\1(a\\1)\\1)\\1",
280 "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))"); 284 "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))");
281 CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1", 285 CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1",
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 CHECK_MIN_MAX("a[bc]d", 3, 3); 372 CHECK_MIN_MAX("a[bc]d", 3, 3);
369 CHECK_MIN_MAX("a|bc", 1, 2); 373 CHECK_MIN_MAX("a|bc", 1, 2);
370 CHECK_MIN_MAX("ab|c", 1, 2); 374 CHECK_MIN_MAX("ab|c", 1, 2);
371 CHECK_MIN_MAX("a||bc", 0, 2); 375 CHECK_MIN_MAX("a||bc", 0, 2);
372 CHECK_MIN_MAX("|", 0, 0); 376 CHECK_MIN_MAX("|", 0, 0);
373 CHECK_MIN_MAX("(?:ab)", 2, 2); 377 CHECK_MIN_MAX("(?:ab)", 2, 2);
374 CHECK_MIN_MAX("(?:ab|cde)", 2, 3); 378 CHECK_MIN_MAX("(?:ab|cde)", 2, 3);
375 CHECK_MIN_MAX("(?:ab)|cde", 2, 3); 379 CHECK_MIN_MAX("(?:ab)|cde", 2, 3);
376 CHECK_MIN_MAX("(ab)", 2, 2); 380 CHECK_MIN_MAX("(ab)", 2, 2);
377 CHECK_MIN_MAX("(ab|cde)", 2, 3); 381 CHECK_MIN_MAX("(ab|cde)", 2, 3);
378 CHECK_MIN_MAX("(ab)\\1", 2, 4); 382 CHECK_MIN_MAX("(ab)\\1", 2, RegExpTree::kInfinity);
379 CHECK_MIN_MAX("(ab|cde)\\1", 2, 6); 383 CHECK_MIN_MAX("(ab|cde)\\1", 2, RegExpTree::kInfinity);
380 CHECK_MIN_MAX("(?:ab)?", 0, 2); 384 CHECK_MIN_MAX("(?:ab)?", 0, 2);
381 CHECK_MIN_MAX("(?:ab)*", 0, RegExpTree::kInfinity); 385 CHECK_MIN_MAX("(?:ab)*", 0, RegExpTree::kInfinity);
382 CHECK_MIN_MAX("(?:ab)+", 2, RegExpTree::kInfinity); 386 CHECK_MIN_MAX("(?:ab)+", 2, RegExpTree::kInfinity);
383 CHECK_MIN_MAX("a?", 0, 1); 387 CHECK_MIN_MAX("a?", 0, 1);
384 CHECK_MIN_MAX("a*", 0, RegExpTree::kInfinity); 388 CHECK_MIN_MAX("a*", 0, RegExpTree::kInfinity);
385 CHECK_MIN_MAX("a+", 1, RegExpTree::kInfinity); 389 CHECK_MIN_MAX("a+", 1, RegExpTree::kInfinity);
386 CHECK_MIN_MAX("a??", 0, 1); 390 CHECK_MIN_MAX("a??", 0, 1);
387 CHECK_MIN_MAX("a*?", 0, RegExpTree::kInfinity); 391 CHECK_MIN_MAX("a*?", 0, RegExpTree::kInfinity);
388 CHECK_MIN_MAX("a+?", 1, RegExpTree::kInfinity); 392 CHECK_MIN_MAX("a+?", 1, RegExpTree::kInfinity);
389 CHECK_MIN_MAX("(?:a?)?", 0, 1); 393 CHECK_MIN_MAX("(?:a?)?", 0, 1);
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 1840
1837 ZoneList<CharacterRange> first_only(4, &zone); 1841 ZoneList<CharacterRange> first_only(4, &zone);
1838 ZoneList<CharacterRange> second_only(4, &zone); 1842 ZoneList<CharacterRange> second_only(4, &zone);
1839 ZoneList<CharacterRange> both(4, &zone); 1843 ZoneList<CharacterRange> both(4, &zone);
1840 } 1844 }
1841 1845
1842 1846
1843 TEST(Graph) { 1847 TEST(Graph) {
1844 Execute("\\b\\w+\\b", false, true, true); 1848 Execute("\\b\\w+\\b", false, true, true);
1845 } 1849 }
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/harmony/regexp-lookbehind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698