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

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

Issue 3585010: API: expose RegExp. (Closed)
Patch Set: Created 10 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 unified diff | Download patch
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 11601 matching lines...) Expand 10 before | Expand all | Expand 10 after
11612 ExpectString("readCell()", "value"); 11612 ExpectString("readCell()", "value");
11613 } 11613 }
11614 { 11614 {
11615 v8::HandleScope scope; 11615 v8::HandleScope scope;
11616 LocalContext context2; 11616 LocalContext context2;
11617 // Hold the code object in the second context. 11617 // Hold the code object in the second context.
11618 CompileRun(function_code); 11618 CompileRun(function_code);
11619 CheckSurvivingGlobalObjectsCount(1); 11619 CheckSurvivingGlobalObjectsCount(1);
11620 } 11620 }
11621 } 11621 }
11622
11623
11624 TEST(RegExp) {
11625 v8::HandleScope scope;
11626 LocalContext context;
11627
11628 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.
11629 CHECK(re->IsRegExp());
11630 CHECK(re->GetSource()->Equals(v8_str("foo")));
11631 CHECK_EQ(re->GetFlags(), v8::RegExp::kNone);
11632
11633 re = v8::RegExp::New(v8_str("bar"),
11634 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
11635 v8::RegExp::kGlobal));
11636 CHECK(re->IsRegExp());
11637 CHECK(re->GetSource()->Equals(v8_str("bar")));
11638 CHECK_EQ(static_cast<int>(re->GetFlags()),
11639 v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal);
11640
11641 re = v8::RegExp::New(v8_str("baz"),
11642 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
11643 v8::RegExp::kMultiline));
11644 CHECK(re->IsRegExp());
11645 CHECK(re->GetSource()->Equals(v8_str("baz")));
11646 CHECK_EQ(static_cast<int>(re->GetFlags()),
11647 v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline);
11648
11649 re = CompileRun("/quux/").As<v8::RegExp>();
11650 CHECK(re->IsRegExp());
11651 CHECK(re->GetSource()->Equals(v8_str("quux")));
11652 CHECK_EQ(re->GetFlags(), v8::RegExp::kNone);
11653
11654 re = CompileRun("/quux/gm").As<v8::RegExp>();
11655 CHECK(re->IsRegExp());
11656 CHECK(re->GetSource()->Equals(v8_str("quux")));
11657 CHECK_EQ(static_cast<int>(re->GetFlags()),
11658 v8::RegExp::kGlobal | v8::RegExp::kMultiline);
11659
11660 // Override the RegExp constructor and check the API constructor
11661 // still works.
11662 CompileRun("RegExp = function() {}");
11663
11664 re = v8::RegExp::New(v8_str("foobar"), v8::RegExp::kNone);
11665 CHECK(re->IsRegExp());
11666 CHECK(re->GetSource()->Equals(v8_str("foobar")));
11667 CHECK_EQ(re->GetFlags(), v8::RegExp::kNone);
11668
11669 re = v8::RegExp::New(v8_str("foobarbaz"),
11670 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
11671 v8::RegExp::kMultiline));
11672 CHECK(re->IsRegExp());
11673 CHECK(re->GetSource()->Equals(v8_str("foobarbaz")));
11674 CHECK_EQ(static_cast<int>(re->GetFlags()),
11675 v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline);
11676 }
OLDNEW
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698