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

Unified Diff: test/cctest/test-regexp.cc

Issue 9690: Rename codegen to macro-assembler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« src/interpreter-re2k.cc ('K') | « src/regexp-macro-assembler-re2k.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-regexp.cc
===================================================================
--- test/cctest/test-regexp.cc (revision 707)
+++ test/cctest/test-regexp.cc (working copy)
@@ -495,8 +495,8 @@
__ CheckChar('o', &advance);
__ LoadCurrentChar(2);
__ CheckChar('o', &advance);
- __ SetRegister(0);
- __ SetRegister(1, 2);
+ __ SetRegisterToCurrentPosition(0);
+ __ SetRegisterToCurrentPosition(1, 2);
__ Succeed();
v8::HandleScope scope;
@@ -518,3 +518,84 @@
CHECK_EQ(3, captures[0]);
CHECK_EQ(5, captures[1]);
}
+
+
+TEST(Assembler2) {
+ V8::Initialize(NULL);
+ byte codes[1024];
+ Re2kAssembler assembler(Vector<byte>(codes, 1024));
+#define __ assembler.
+ // /^.*foo/
+ Label more_dots;
+ Label unwind_dot;
+ Label failure;
+ Label foo;
+ Label foo_failed;
+ Label dot_match;
+ // ^
+ __ PushCurrentPosition();
+ __ PushRegister(0);
+ __ SetRegisterToCurrentPosition(0);
+ __ PushBacktrack(&failure);
+ __ GoTo(&dot_match);
+ // .*
+ __ Bind(&more_dots);
+ __ AdvanceCP();
+ __ Bind(&dot_match);
+ __ PushCurrentPosition();
+ __ PushBacktrack(&unwind_dot);
+ __ LoadCurrentChar();
+ __ CheckNotEnd(&foo);
+ __ CheckChar('\n', &more_dots);
+ // foo
+ __ Bind(&foo);
+ __ CheckChar('f', &foo_failed);
+ __ LoadCurrentChar(1);
+ __ CheckChar('o', &foo_failed);
+ __ LoadCurrentChar(2);
+ __ CheckChar('o', &foo_failed);
+ __ SetRegisterToCurrentPosition(1, 2);
+ __ Succeed();
+ __ Break();
+
+ __ Bind(&foo_failed);
+ __ PopBacktrack();
+ __ Break();
+
+ __ Bind(&unwind_dot);
+ __ PopCurrentPosition();
+ __ LoadCurrentChar();
+ __ GoTo(&foo);
+
+ __ Bind(&failure);
+ __ PopRegister(0);
+ __ PopCurrentPosition();
+ __ Fail();
+
+ v8::HandleScope scope;
+ Handle<ByteArray> array = Factory::NewByteArray(assembler.length());
+ assembler.Copy(array->GetDataStartAddress());
+ int captures[2];
+
+ Handle<String> f1 =
+ Factory::NewStringFromAscii(CStrVector("Now is the time"));
+ CHECK(!Re2kInterpreter::Match(*array, *f1, captures, 0));
+
+ Handle<String> f2 = Factory::NewStringFromAscii(CStrVector("foo bar baz"));
+ CHECK(Re2kInterpreter::Match(*array, *f2, captures, 0));
+ CHECK_EQ(0, captures[0]);
+ CHECK_EQ(2, captures[1]);
+
+ Handle<String> f3 = Factory::NewStringFromAscii(CStrVector("tomfoolery"));
+ CHECK(Re2kInterpreter::Match(*array, *f3, captures, 0));
+ CHECK_EQ(0, captures[0]);
+ CHECK_EQ(5, captures[1]);
+
+ Handle<String> f4 = Factory::NewStringFromAscii(CStrVector("football buffoonery"));
+ CHECK(Re2kInterpreter::Match(*array, *f4, captures, 0));
+ CHECK_EQ(0, captures[0]);
+ CHECK_EQ(14, captures[1]);
+
+ Handle<String> f5 = Factory::NewStringFromAscii(CStrVector("walking\nbarefoot"));
+ CHECK(!Re2kInterpreter::Match(*array, *f5, captures, 0));
+}
« src/interpreter-re2k.cc ('K') | « src/regexp-macro-assembler-re2k.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698