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

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

Issue 7860011: Rename SmartPointer to SmartArrayPointer. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: rebase it again to get more fixes Created 9 years, 3 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 | « test/cctest/test-parsing.cc ('k') | test/cctest/test-reloc-info.cc » ('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 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 static bool CheckParse(const char* input) { 72 static bool CheckParse(const char* input) {
73 V8::Initialize(NULL); 73 V8::Initialize(NULL);
74 v8::HandleScope scope; 74 v8::HandleScope scope;
75 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); 75 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
76 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 76 FlatStringReader reader(Isolate::Current(), CStrVector(input));
77 RegExpCompileData result; 77 RegExpCompileData result;
78 return v8::internal::RegExpParser::ParseRegExp(&reader, false, &result); 78 return v8::internal::RegExpParser::ParseRegExp(&reader, false, &result);
79 } 79 }
80 80
81 81
82 static SmartPointer<const char> Parse(const char* input) { 82 static SmartArrayPointer<const char> Parse(const char* input) {
83 V8::Initialize(NULL); 83 V8::Initialize(NULL);
84 v8::HandleScope scope; 84 v8::HandleScope scope;
85 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); 85 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
86 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 86 FlatStringReader reader(Isolate::Current(), CStrVector(input));
87 RegExpCompileData result; 87 RegExpCompileData result;
88 CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); 88 CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
89 CHECK(result.tree != NULL); 89 CHECK(result.tree != NULL);
90 CHECK(result.error.is_null()); 90 CHECK(result.error.is_null());
91 SmartPointer<const char> output = result.tree->ToString(); 91 SmartArrayPointer<const char> output = result.tree->ToString();
92 return output; 92 return output;
93 } 93 }
94 94
95 static bool CheckSimple(const char* input) { 95 static bool CheckSimple(const char* input) {
96 V8::Initialize(NULL); 96 V8::Initialize(NULL);
97 v8::HandleScope scope; 97 v8::HandleScope scope;
98 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); 98 unibrow::Utf8InputBuffer<> buffer(input, StrLength(input));
99 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); 99 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
100 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 100 FlatStringReader reader(Isolate::Current(), CStrVector(input));
101 RegExpCompileData result; 101 RegExpCompileData result;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 static void ExpectError(const char* input, 384 static void ExpectError(const char* input,
385 const char* expected) { 385 const char* expected) {
386 V8::Initialize(NULL); 386 V8::Initialize(NULL);
387 v8::HandleScope scope; 387 v8::HandleScope scope;
388 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); 388 ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
389 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 389 FlatStringReader reader(Isolate::Current(), CStrVector(input));
390 RegExpCompileData result; 390 RegExpCompileData result;
391 CHECK(!v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); 391 CHECK(!v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
392 CHECK(result.tree == NULL); 392 CHECK(result.tree == NULL);
393 CHECK(!result.error.is_null()); 393 CHECK(!result.error.is_null());
394 SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS); 394 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
395 CHECK_EQ(expected, *str); 395 CHECK_EQ(expected, *str);
396 } 396 }
397 397
398 398
399 TEST(Errors) { 399 TEST(Errors) {
400 V8::Initialize(NULL); 400 V8::Initialize(NULL);
401 const char* kEndBackslash = "\\ at end of pattern"; 401 const char* kEndBackslash = "\\ at end of pattern";
402 ExpectError("\\", kEndBackslash); 402 ExpectError("\\", kEndBackslash);
403 const char* kUnterminatedGroup = "Unterminated group"; 403 const char* kUnterminatedGroup = "Unterminated group";
404 ExpectError("(foo", kUnterminatedGroup); 404 ExpectError("(foo", kUnterminatedGroup);
(...skipping 11 matching lines...) Expand all
416 ExpectError("{1,}", kNothingToRepeat); 416 ExpectError("{1,}", kNothingToRepeat);
417 417
418 // Check that we don't allow more than kMaxCapture captures 418 // Check that we don't allow more than kMaxCapture captures
419 const int kMaxCaptures = 1 << 16; // Must match RegExpParser::kMaxCaptures. 419 const int kMaxCaptures = 1 << 16; // Must match RegExpParser::kMaxCaptures.
420 const char* kTooManyCaptures = "Too many captures"; 420 const char* kTooManyCaptures = "Too many captures";
421 HeapStringAllocator allocator; 421 HeapStringAllocator allocator;
422 StringStream accumulator(&allocator); 422 StringStream accumulator(&allocator);
423 for (int i = 0; i <= kMaxCaptures; i++) { 423 for (int i = 0; i <= kMaxCaptures; i++) {
424 accumulator.Add("()"); 424 accumulator.Add("()");
425 } 425 }
426 SmartPointer<const char> many_captures(accumulator.ToCString()); 426 SmartArrayPointer<const char> many_captures(accumulator.ToCString());
427 ExpectError(*many_captures, kTooManyCaptures); 427 ExpectError(*many_captures, kTooManyCaptures);
428 } 428 }
429 429
430 430
431 static bool IsDigit(uc16 c) { 431 static bool IsDigit(uc16 c) {
432 return ('0' <= c && c <= '9'); 432 return ('0' <= c && c <= '9');
433 } 433 }
434 434
435 435
436 static bool NotDigit(uc16 c) { 436 static bool NotDigit(uc16 c) {
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 bool in_second = CharacterInSet(&l2, i); 1824 bool in_second = CharacterInSet(&l2, i);
1825 CHECK((in_first || in_second) == CharacterInSet(&all, i)); 1825 CHECK((in_first || in_second) == CharacterInSet(&all, i));
1826 } 1826 }
1827 } 1827 }
1828 1828
1829 1829
1830 TEST(Graph) { 1830 TEST(Graph) {
1831 V8::Initialize(NULL); 1831 V8::Initialize(NULL);
1832 Execute("\\b\\w+\\b", false, true, true); 1832 Execute("\\b\\w+\\b", false, true, true);
1833 } 1833 }
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/cctest/test-reloc-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698