Chromium Code Reviews| Index: test/cctest/test-api.cc |
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
| index f1a6eada40e8619d92bdb255ce5f8f9f261fc62a..3b96c916457dc36abcfff399bfce6e1567104285 100644 |
| --- a/test/cctest/test-api.cc |
| +++ b/test/cctest/test-api.cc |
| @@ -11619,3 +11619,58 @@ TEST(GlobalLoadICGC) { |
| CheckSurvivingGlobalObjectsCount(1); |
| } |
| } |
| + |
| + |
| +TEST(RegExp) { |
| + v8::HandleScope scope; |
| + LocalContext context; |
| + |
| + v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); |
|
antonm
2010/10/04 14:44:55
maybe add a test case that checks that regexps cre
Vitaly Repeshko
2010/10/04 15:04:42
Done.
|
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("foo"))); |
| + CHECK_EQ(re->GetFlags(), v8::RegExp::kNone); |
| + |
| + re = v8::RegExp::New(v8_str("bar"), |
| + static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
| + v8::RegExp::kGlobal)); |
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("bar"))); |
| + CHECK_EQ(static_cast<int>(re->GetFlags()), |
| + v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal); |
| + |
| + re = v8::RegExp::New(v8_str("baz"), |
| + static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
| + v8::RegExp::kMultiline)); |
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("baz"))); |
| + CHECK_EQ(static_cast<int>(re->GetFlags()), |
| + v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline); |
| + |
| + re = CompileRun("/quux/").As<v8::RegExp>(); |
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("quux"))); |
| + CHECK_EQ(re->GetFlags(), v8::RegExp::kNone); |
| + |
| + re = CompileRun("/quux/gm").As<v8::RegExp>(); |
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("quux"))); |
| + CHECK_EQ(static_cast<int>(re->GetFlags()), |
| + v8::RegExp::kGlobal | v8::RegExp::kMultiline); |
| + |
| + // Override the RegExp constructor and check the API constructor |
| + // still works. |
| + CompileRun("RegExp = function() {}"); |
| + |
| + re = v8::RegExp::New(v8_str("foobar"), v8::RegExp::kNone); |
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("foobar"))); |
| + CHECK_EQ(re->GetFlags(), v8::RegExp::kNone); |
| + |
| + re = v8::RegExp::New(v8_str("foobarbaz"), |
| + static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase | |
| + v8::RegExp::kMultiline)); |
| + CHECK(re->IsRegExp()); |
| + CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); |
| + CHECK_EQ(static_cast<int>(re->GetFlags()), |
| + v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline); |
| +} |