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

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

Issue 24265002: bulk replace v8::Isolate::GetCurrent in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-random.cc ('k') | test/cctest/test-serialize.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 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "ia32/macro-assembler-ia32.h" 64 #include "ia32/macro-assembler-ia32.h"
65 #include "ia32/regexp-macro-assembler-ia32.h" 65 #include "ia32/regexp-macro-assembler-ia32.h"
66 #endif 66 #endif
67 #endif // V8_INTERPRETED_REGEXP 67 #endif // V8_INTERPRETED_REGEXP
68 68
69 using namespace v8::internal; 69 using namespace v8::internal;
70 70
71 71
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(v8::Isolate::GetCurrent()); 74 v8::HandleScope scope(CcTest::isolate());
75 Zone zone(Isolate::Current()); 75 Zone zone(Isolate::Current());
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( 78 return v8::internal::RegExpParser::ParseRegExp(
79 &reader, false, &result, &zone); 79 &reader, false, &result, &zone);
80 } 80 }
81 81
82 82
83 static SmartArrayPointer<const char> Parse(const char* input) { 83 static SmartArrayPointer<const char> Parse(const char* input) {
84 V8::Initialize(NULL); 84 V8::Initialize(NULL);
85 v8::HandleScope scope(v8::Isolate::GetCurrent()); 85 v8::HandleScope scope(CcTest::isolate());
86 Zone zone(Isolate::Current()); 86 Zone zone(Isolate::Current());
87 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 87 FlatStringReader reader(Isolate::Current(), CStrVector(input));
88 RegExpCompileData result; 88 RegExpCompileData result;
89 CHECK(v8::internal::RegExpParser::ParseRegExp( 89 CHECK(v8::internal::RegExpParser::ParseRegExp(
90 &reader, false, &result, &zone)); 90 &reader, false, &result, &zone));
91 CHECK(result.tree != NULL); 91 CHECK(result.tree != NULL);
92 CHECK(result.error.is_null()); 92 CHECK(result.error.is_null());
93 SmartArrayPointer<const char> output = result.tree->ToString(&zone); 93 SmartArrayPointer<const char> output = result.tree->ToString(&zone);
94 return output; 94 return output;
95 } 95 }
96 96
97 97
98 static bool CheckSimple(const char* input) { 98 static bool CheckSimple(const char* input) {
99 V8::Initialize(NULL); 99 V8::Initialize(NULL);
100 v8::HandleScope scope(v8::Isolate::GetCurrent()); 100 v8::HandleScope scope(CcTest::isolate());
101 Zone zone(Isolate::Current()); 101 Zone zone(Isolate::Current());
102 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 102 FlatStringReader reader(Isolate::Current(), CStrVector(input));
103 RegExpCompileData result; 103 RegExpCompileData result;
104 CHECK(v8::internal::RegExpParser::ParseRegExp( 104 CHECK(v8::internal::RegExpParser::ParseRegExp(
105 &reader, false, &result, &zone)); 105 &reader, false, &result, &zone));
106 CHECK(result.tree != NULL); 106 CHECK(result.tree != NULL);
107 CHECK(result.error.is_null()); 107 CHECK(result.error.is_null());
108 return result.simple; 108 return result.simple;
109 } 109 }
110 110
111 struct MinMaxPair { 111 struct MinMaxPair {
112 int min_match; 112 int min_match;
113 int max_match; 113 int max_match;
114 }; 114 };
115 115
116 116
117 static MinMaxPair CheckMinMaxMatch(const char* input) { 117 static MinMaxPair CheckMinMaxMatch(const char* input) {
118 V8::Initialize(NULL); 118 V8::Initialize(NULL);
119 v8::HandleScope scope(v8::Isolate::GetCurrent()); 119 v8::HandleScope scope(CcTest::isolate());
120 Zone zone(Isolate::Current()); 120 Zone zone(Isolate::Current());
121 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 121 FlatStringReader reader(Isolate::Current(), CStrVector(input));
122 RegExpCompileData result; 122 RegExpCompileData result;
123 CHECK(v8::internal::RegExpParser::ParseRegExp( 123 CHECK(v8::internal::RegExpParser::ParseRegExp(
124 &reader, false, &result, &zone)); 124 &reader, false, &result, &zone));
125 CHECK(result.tree != NULL); 125 CHECK(result.tree != NULL);
126 CHECK(result.error.is_null()); 126 CHECK(result.error.is_null());
127 int min_match = result.tree->min_match(); 127 int min_match = result.tree->min_match();
128 int max_match = result.tree->max_match(); 128 int max_match = result.tree->max_match();
129 MinMaxPair pair = { min_match, max_match }; 129 MinMaxPair pair = { min_match, max_match };
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 TEST(ParserRegression) { 383 TEST(ParserRegression) {
384 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 384 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])");
385 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 385 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
386 CHECK_PARSE_EQ("{", "'{'"); 386 CHECK_PARSE_EQ("{", "'{'");
387 CHECK_PARSE_EQ("a|", "(| 'a' %)"); 387 CHECK_PARSE_EQ("a|", "(| 'a' %)");
388 } 388 }
389 389
390 static void ExpectError(const char* input, 390 static void ExpectError(const char* input,
391 const char* expected) { 391 const char* expected) {
392 V8::Initialize(NULL); 392 V8::Initialize(NULL);
393 v8::HandleScope scope(v8::Isolate::GetCurrent()); 393 v8::HandleScope scope(CcTest::isolate());
394 Zone zone(Isolate::Current()); 394 Zone zone(Isolate::Current());
395 FlatStringReader reader(Isolate::Current(), CStrVector(input)); 395 FlatStringReader reader(Isolate::Current(), CStrVector(input));
396 RegExpCompileData result; 396 RegExpCompileData result;
397 CHECK(!v8::internal::RegExpParser::ParseRegExp( 397 CHECK(!v8::internal::RegExpParser::ParseRegExp(
398 &reader, false, &result, &zone)); 398 &reader, false, &result, &zone));
399 CHECK(result.tree == NULL); 399 CHECK(result.tree == NULL);
400 CHECK(!result.error.is_null()); 400 CHECK(!result.error.is_null());
401 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); 401 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
402 CHECK_EQ(expected, *str); 402 CHECK_EQ(expected, *str);
403 } 403 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 is_ascii, 526 is_ascii,
527 zone); 527 zone);
528 return compile_data.node; 528 return compile_data.node;
529 } 529 }
530 530
531 531
532 static void Execute(const char* input, 532 static void Execute(const char* input,
533 bool multiline, 533 bool multiline,
534 bool is_ascii, 534 bool is_ascii,
535 bool dot_output = false) { 535 bool dot_output = false) {
536 v8::HandleScope scope(v8::Isolate::GetCurrent()); 536 v8::HandleScope scope(CcTest::isolate());
537 Zone zone(Isolate::Current()); 537 Zone zone(Isolate::Current());
538 RegExpNode* node = Compile(input, multiline, is_ascii, &zone); 538 RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
539 USE(node); 539 USE(node);
540 #ifdef DEBUG 540 #ifdef DEBUG
541 if (dot_output) { 541 if (dot_output) {
542 RegExpEngine::DotPrint(input, node, false); 542 RegExpEngine::DotPrint(input, node, false);
543 exit(0); 543 exit(0);
544 } 544 }
545 #endif // DEBUG 545 #endif // DEBUG
546 } 546 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; 703 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler;
704 #elif V8_TARGET_ARCH_ARM 704 #elif V8_TARGET_ARCH_ARM
705 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; 705 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler;
706 #elif V8_TARGET_ARCH_MIPS 706 #elif V8_TARGET_ARCH_MIPS
707 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; 707 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
708 #endif 708 #endif
709 709
710 class ContextInitializer { 710 class ContextInitializer {
711 public: 711 public:
712 ContextInitializer() 712 ContextInitializer()
713 : scope_(v8::Isolate::GetCurrent()), 713 : scope_(CcTest::isolate()),
714 env_(v8::Context::New(v8::Isolate::GetCurrent())) { 714 env_(v8::Context::New(CcTest::isolate())) {
715 env_->Enter(); 715 env_->Enter();
716 } 716 }
717 ~ContextInitializer() { 717 ~ContextInitializer() {
718 env_->Exit(); 718 env_->Exit();
719 } 719 }
720 private: 720 private:
721 v8::HandleScope scope_; 721 v8::HandleScope scope_;
722 v8::Handle<v8::Context> env_; 722 v8::Handle<v8::Context> env_;
723 }; 723 };
724 724
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 ZoneList<CharacterRange> first_only(4, &zone); 1810 ZoneList<CharacterRange> first_only(4, &zone);
1811 ZoneList<CharacterRange> second_only(4, &zone); 1811 ZoneList<CharacterRange> second_only(4, &zone);
1812 ZoneList<CharacterRange> both(4, &zone); 1812 ZoneList<CharacterRange> both(4, &zone);
1813 } 1813 }
1814 1814
1815 1815
1816 TEST(Graph) { 1816 TEST(Graph) {
1817 V8::Initialize(NULL); 1817 V8::Initialize(NULL);
1818 Execute("\\b\\w+\\b", false, true, true); 1818 Execute("\\b\\w+\\b", false, true, true);
1819 } 1819 }
OLDNEW
« no previous file with comments | « test/cctest/test-random.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698