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

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

Issue 12826: RegExp stack and zone limits. (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/zone-inl.h ('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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "macro-assembler-ia32.h" 44 #include "macro-assembler-ia32.h"
45 #include "regexp-macro-assembler-ia32.h" 45 #include "regexp-macro-assembler-ia32.h"
46 #endif 46 #endif
47 #include "interpreter-irregexp.h" 47 #include "interpreter-irregexp.h"
48 48
49 49
50 using namespace v8::internal; 50 using namespace v8::internal;
51 51
52 52
53 static SmartPointer<const char> Parse(const char* input) { 53 static SmartPointer<const char> Parse(const char* input) {
54 V8::Initialize(NULL);
54 v8::HandleScope scope; 55 v8::HandleScope scope;
55 ZoneScope zone_scope(DELETE_ON_EXIT); 56 ZoneScope zone_scope(DELETE_ON_EXIT);
56 FlatStringReader reader(CStrVector(input)); 57 FlatStringReader reader(CStrVector(input));
57 RegExpParseResult result; 58 RegExpParseResult result;
58 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 59 CHECK(v8::internal::ParseRegExp(&reader, false, &result));
59 CHECK(result.tree != NULL); 60 CHECK(result.tree != NULL);
60 CHECK(result.error.is_null()); 61 CHECK(result.error.is_null());
61 SmartPointer<const char> output = result.tree->ToString(); 62 SmartPointer<const char> output = result.tree->ToString();
62 return output; 63 return output;
63 } 64 }
64 65
65 static bool ParseEscapes(const char* input) { 66 static bool ParseEscapes(const char* input) {
67 V8::Initialize(NULL);
66 v8::HandleScope scope; 68 v8::HandleScope scope;
67 unibrow::Utf8InputBuffer<> buffer(input, strlen(input)); 69 unibrow::Utf8InputBuffer<> buffer(input, strlen(input));
68 ZoneScope zone_scope(DELETE_ON_EXIT); 70 ZoneScope zone_scope(DELETE_ON_EXIT);
69 FlatStringReader reader(CStrVector(input)); 71 FlatStringReader reader(CStrVector(input));
70 RegExpParseResult result; 72 RegExpParseResult result;
71 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 73 CHECK(v8::internal::ParseRegExp(&reader, false, &result));
72 CHECK(result.tree != NULL); 74 CHECK(result.tree != NULL);
73 CHECK(result.error.is_null()); 75 CHECK(result.error.is_null());
74 return result.has_character_escapes; 76 return result.has_character_escapes;
75 } 77 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 248
247 TEST(ParserRegression) { 249 TEST(ParserRegression) {
248 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 250 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])");
249 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 251 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
250 CHECK_PARSE_EQ("{", "'{'"); 252 CHECK_PARSE_EQ("{", "'{'");
251 CHECK_PARSE_EQ("a|", "(| 'a' %)"); 253 CHECK_PARSE_EQ("a|", "(| 'a' %)");
252 } 254 }
253 255
254 static void ExpectError(const char* input, 256 static void ExpectError(const char* input,
255 const char* expected) { 257 const char* expected) {
258 V8::Initialize(NULL);
256 v8::HandleScope scope; 259 v8::HandleScope scope;
257 ZoneScope zone_scope(DELETE_ON_EXIT); 260 ZoneScope zone_scope(DELETE_ON_EXIT);
258 FlatStringReader reader(CStrVector(input)); 261 FlatStringReader reader(CStrVector(input));
259 RegExpParseResult result; 262 RegExpParseResult result;
260 CHECK_EQ(false, v8::internal::ParseRegExp(&reader, false, &result)); 263 CHECK_EQ(false, v8::internal::ParseRegExp(&reader, false, &result));
261 CHECK(result.tree == NULL); 264 CHECK(result.tree == NULL);
262 CHECK(!result.error.is_null()); 265 CHECK(!result.error.is_null());
263 SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS); 266 SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS);
264 CHECK_EQ(expected, *str); 267 CHECK_EQ(expected, *str);
265 } 268 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 TestCharacterClassEscapes('d', IsDigit); 368 TestCharacterClassEscapes('d', IsDigit);
366 TestCharacterClassEscapes('D', NotDigit); 369 TestCharacterClassEscapes('D', NotDigit);
367 TestCharacterClassEscapes('s', IsWhiteSpace); 370 TestCharacterClassEscapes('s', IsWhiteSpace);
368 TestCharacterClassEscapes('S', NotWhiteSpace); 371 TestCharacterClassEscapes('S', NotWhiteSpace);
369 TestCharacterClassEscapes('w', IsWord); 372 TestCharacterClassEscapes('w', IsWord);
370 TestCharacterClassEscapes('W', NotWord); 373 TestCharacterClassEscapes('W', NotWord);
371 } 374 }
372 375
373 376
374 static RegExpNode* Compile(const char* input, bool multiline) { 377 static RegExpNode* Compile(const char* input, bool multiline) {
378 V8::Initialize(NULL);
375 FlatStringReader reader(CStrVector(input)); 379 FlatStringReader reader(CStrVector(input));
376 RegExpParseResult result; 380 RegExpParseResult result;
377 if (!v8::internal::ParseRegExp(&reader, multiline, &result)) 381 if (!v8::internal::ParseRegExp(&reader, multiline, &result))
378 return NULL; 382 return NULL;
379 RegExpNode* node = NULL; 383 RegExpNode* node = NULL;
380 RegExpEngine::Compile(&result, &node, false, multiline); 384 RegExpEngine::Compile(&result, &node, false, multiline);
381 return node; 385 return node;
382 } 386 }
383 387
384 388
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 // whole block at a time. 1159 // whole block at a time.
1156 TestSimpleRangeCaseIndependence(CharacterRange('A', 'k'), 1160 TestSimpleRangeCaseIndependence(CharacterRange('A', 'k'),
1157 CharacterRange('a', 'z')); 1161 CharacterRange('a', 'z'));
1158 } 1162 }
1159 1163
1160 1164
1161 TEST(Graph) { 1165 TEST(Graph) {
1162 V8::Initialize(NULL); 1166 V8::Initialize(NULL);
1163 Execute("foo$(?!bar)", false, true); 1167 Execute("foo$(?!bar)", false, true);
1164 } 1168 }
OLDNEW
« src/parser.cc ('K') | « src/zone-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698