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

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

Issue 3602007: Fix a pair of compilation failure bugs in test files due to r5576. (Closed)
Patch Set: Created 10 years, 2 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
« no previous file with comments | « src/parser.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 using namespace v8::internal; 58 using namespace v8::internal;
59 59
60 60
61 static bool CheckParse(const char* input) { 61 static bool CheckParse(const char* input) {
62 V8::Initialize(NULL); 62 V8::Initialize(NULL);
63 v8::HandleScope scope; 63 v8::HandleScope scope;
64 ZoneScope zone_scope(DELETE_ON_EXIT); 64 ZoneScope zone_scope(DELETE_ON_EXIT);
65 FlatStringReader reader(CStrVector(input)); 65 FlatStringReader reader(CStrVector(input));
66 RegExpCompileData result; 66 RegExpCompileData result;
67 return v8::internal::ParseRegExp(&reader, false, &result); 67 return v8::internal::Parser::ParseRegExp(&reader, false, &result);
68 } 68 }
69 69
70 70
71 static SmartPointer<const char> Parse(const char* input) { 71 static SmartPointer<const char> Parse(const char* input) {
72 V8::Initialize(NULL); 72 V8::Initialize(NULL);
73 v8::HandleScope scope; 73 v8::HandleScope scope;
74 ZoneScope zone_scope(DELETE_ON_EXIT); 74 ZoneScope zone_scope(DELETE_ON_EXIT);
75 FlatStringReader reader(CStrVector(input)); 75 FlatStringReader reader(CStrVector(input));
76 RegExpCompileData result; 76 RegExpCompileData result;
77 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 77 CHECK(v8::internal::Parser::ParseRegExp(&reader, false, &result));
78 CHECK(result.tree != NULL); 78 CHECK(result.tree != NULL);
79 CHECK(result.error.is_null()); 79 CHECK(result.error.is_null());
80 SmartPointer<const char> output = result.tree->ToString(); 80 SmartPointer<const char> output = result.tree->ToString();
81 return output; 81 return output;
82 } 82 }
83 83
84 static bool CheckSimple(const char* input) { 84 static bool CheckSimple(const char* input) {
85 V8::Initialize(NULL); 85 V8::Initialize(NULL);
86 v8::HandleScope scope; 86 v8::HandleScope scope;
87 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); 87 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input));
88 ZoneScope zone_scope(DELETE_ON_EXIT); 88 ZoneScope zone_scope(DELETE_ON_EXIT);
89 FlatStringReader reader(CStrVector(input)); 89 FlatStringReader reader(CStrVector(input));
90 RegExpCompileData result; 90 RegExpCompileData result;
91 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 91 CHECK(v8::internal::Parser::ParseRegExp(&reader, false, &result));
92 CHECK(result.tree != NULL); 92 CHECK(result.tree != NULL);
93 CHECK(result.error.is_null()); 93 CHECK(result.error.is_null());
94 return result.simple; 94 return result.simple;
95 } 95 }
96 96
97 struct MinMaxPair { 97 struct MinMaxPair {
98 int min_match; 98 int min_match;
99 int max_match; 99 int max_match;
100 }; 100 };
101 101
102 static MinMaxPair CheckMinMaxMatch(const char* input) { 102 static MinMaxPair CheckMinMaxMatch(const char* input) {
103 V8::Initialize(NULL); 103 V8::Initialize(NULL);
104 v8::HandleScope scope; 104 v8::HandleScope scope;
105 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); 105 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input));
106 ZoneScope zone_scope(DELETE_ON_EXIT); 106 ZoneScope zone_scope(DELETE_ON_EXIT);
107 FlatStringReader reader(CStrVector(input)); 107 FlatStringReader reader(CStrVector(input));
108 RegExpCompileData result; 108 RegExpCompileData result;
109 CHECK(v8::internal::ParseRegExp(&reader, false, &result)); 109 CHECK(v8::internal::Parser::ParseRegExp(&reader, false, &result));
110 CHECK(result.tree != NULL); 110 CHECK(result.tree != NULL);
111 CHECK(result.error.is_null()); 111 CHECK(result.error.is_null());
112 int min_match = result.tree->min_match(); 112 int min_match = result.tree->min_match();
113 int max_match = result.tree->max_match(); 113 int max_match = result.tree->max_match();
114 MinMaxPair pair = { min_match, max_match }; 114 MinMaxPair pair = { min_match, max_match };
115 return pair; 115 return pair;
116 } 116 }
117 117
118 118
119 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) 119 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input))
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 CHECK_PARSE_EQ("a|", "(| 'a' %)"); 358 CHECK_PARSE_EQ("a|", "(| 'a' %)");
359 } 359 }
360 360
361 static void ExpectError(const char* input, 361 static void ExpectError(const char* input,
362 const char* expected) { 362 const char* expected) {
363 V8::Initialize(NULL); 363 V8::Initialize(NULL);
364 v8::HandleScope scope; 364 v8::HandleScope scope;
365 ZoneScope zone_scope(DELETE_ON_EXIT); 365 ZoneScope zone_scope(DELETE_ON_EXIT);
366 FlatStringReader reader(CStrVector(input)); 366 FlatStringReader reader(CStrVector(input));
367 RegExpCompileData result; 367 RegExpCompileData result;
368 CHECK_EQ(false, v8::internal::ParseRegExp(&reader, false, &result)); 368 CHECK_EQ(false, v8::internal::Parser::ParseRegExp(&reader, false, &result));
369 CHECK(result.tree == NULL); 369 CHECK(result.tree == NULL);
370 CHECK(!result.error.is_null()); 370 CHECK(!result.error.is_null());
371 SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS); 371 SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS);
372 CHECK_EQ(expected, *str); 372 CHECK_EQ(expected, *str);
373 } 373 }
374 374
375 375
376 TEST(Errors) { 376 TEST(Errors) {
377 V8::Initialize(NULL); 377 V8::Initialize(NULL);
378 const char* kEndBackslash = "\\ at end of pattern"; 378 const char* kEndBackslash = "\\ at end of pattern";
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 TestCharacterClassEscapes('S', NotWhiteSpace); 466 TestCharacterClassEscapes('S', NotWhiteSpace);
467 TestCharacterClassEscapes('w', IsRegExpWord); 467 TestCharacterClassEscapes('w', IsRegExpWord);
468 TestCharacterClassEscapes('W', NotWord); 468 TestCharacterClassEscapes('W', NotWord);
469 } 469 }
470 470
471 471
472 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { 472 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) {
473 V8::Initialize(NULL); 473 V8::Initialize(NULL);
474 FlatStringReader reader(CStrVector(input)); 474 FlatStringReader reader(CStrVector(input));
475 RegExpCompileData compile_data; 475 RegExpCompileData compile_data;
476 if (!v8::internal::ParseRegExp(&reader, multiline, &compile_data)) 476 if (!v8::internal::Parser::ParseRegExp(&reader, multiline, &compile_data))
477 return NULL; 477 return NULL;
478 Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input)); 478 Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input));
479 RegExpEngine::Compile(&compile_data, false, multiline, pattern, is_ascii); 479 RegExpEngine::Compile(&compile_data, false, multiline, pattern, is_ascii);
480 return compile_data.node; 480 return compile_data.node;
481 } 481 }
482 482
483 483
484 static void Execute(const char* input, 484 static void Execute(const char* input,
485 bool multiline, 485 bool multiline,
486 bool is_ascii, 486 bool is_ascii,
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 bool in_second = CharacterInSet(&l2, i); 1775 bool in_second = CharacterInSet(&l2, i);
1776 CHECK((in_first || in_second) == CharacterInSet(&all, i)); 1776 CHECK((in_first || in_second) == CharacterInSet(&all, i));
1777 } 1777 }
1778 } 1778 }
1779 1779
1780 1780
1781 TEST(Graph) { 1781 TEST(Graph) {
1782 V8::Initialize(NULL); 1782 V8::Initialize(NULL);
1783 Execute("\\b\\w+\\b", false, true, true); 1783 Execute("\\b\\w+\\b", false, true, true);
1784 } 1784 }
OLDNEW
« no previous file with comments | « src/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698