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

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

Issue 9415: Add bytecodes and an interpreter for executing regular expressions. Very... (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
« no previous file with comments | « src/regexp-codegen-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 687)
+++ test/cctest/test-regexp.cc (working copy)
@@ -36,6 +36,8 @@
#include "parser.h"
#include "ast.h"
#include "jsregexp-inl.h"
+#include "assembler-re2k.h"
+#include "interpreter-re2k.h"
using namespace v8::internal;
@@ -430,3 +432,49 @@
}
}
}
+
+
+TEST(Assembler) {
+ V8::Initialize(NULL);
+
+ byte codes[1024];
+ Re2kAssembler assembler(codes, 1024);
+#define __ assembler.
+ Label advance;
+ Label look_for_foo;
+ __ GoTo(&look_for_foo);
+ __ Bind(&advance);
+ __ AdvanceCP();
+ __ Bind(&look_for_foo);
+ __ FailIfWithin(3);
+ __ LoadCurrentChar(0);
+ __ CheckChar('f', &advance);
+ __ LoadCurrentChar(1);
+ __ CheckChar('o', &advance);
+ __ LoadCurrentChar(2);
+ __ CheckChar('o', &advance);
+ __ SetCapture(0);
+ __ SetCapture(1, 2);
+ __ Succeed();
+
+ 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(3, captures[0]);
+ CHECK_EQ(5, captures[1]);
+}
+
+
+
« no previous file with comments | « src/regexp-codegen-re2k.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698