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

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

Issue 26848011: Fix regexp interrupt test. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.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
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index cc946464b26ab47c1aa78a0e9fe5d2e0837b3ea2..741acbc147700da7a598e9026524dc49c7ca59a3 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -1816,3 +1816,36 @@ TEST(Graph) {
V8::Initialize(NULL);
Execute("\\b\\w+\\b", false, true, true);
}
+
+
+class TimeoutThread : public i::Thread {
+ public:
+ explicit TimeoutThread(v8::Isolate* isolate)
+ : Thread("TimeoutThread"), isolate_(isolate) {}
+
+ virtual void Run() {
+ OS::Sleep(500); // Wait a bit before terminating thread.
+ v8::V8::TerminateExecution(isolate_);
+ }
+
+ private:
+ v8::Isolate* isolate_;
+};
+
+
+// Test that a regular expression execution can be interrupted and
+// survive a garbage collection.
+TEST(RegExpInterruption) {
+ v8::HandleScope scope(CcTest::isolate());
+ LocalContext env;
+
+ TimeoutThread timeout_thread(CcTest::isolate());
+ v8::TryCatch try_catch;
+
+ timeout_thread.Start();
+ // Run a regexp that does not terminate in reasonable time unless forced.
+ CompileRun("/((a*)*)*b/.exec('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')");
+ CHECK(try_catch.HasTerminated());
+
+ timeout_thread.Join();
+}
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698