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

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

Issue 3417006: Bring r5483 "Fix direct loading of global function prototypes" to 2.2. (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.2/
Patch Set: Created 10 years, 3 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
« no previous file with comments | « src/x64/stub-cache-x64.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-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 5484)
+++ test/cctest/test-api.cc (working copy)
@@ -11184,3 +11184,72 @@
reresult = CompileRun("str2.charCodeAt(2);");
CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value());
}
+
+
+TEST(StringCheckMultipleContexts) {
+ const char* code =
+ "(function() { return \"a\".charAt(0); })()";
+
+ {
+ // Run the code twice in the first context to initialize the call IC.
+ v8::HandleScope scope;
+ LocalContext context1;
+ ExpectString(code, "a");
+ ExpectString(code, "a");
+ }
+
+ {
+ // Change the String.prototype in the second context and check
+ // that the right function gets called.
+ v8::HandleScope scope;
+ LocalContext context2;
+ CompileRun("String.prototype.charAt = function() { return \"not a\"; }");
+ ExpectString(code, "not a");
+ }
+}
+
+
+TEST(NumberCheckMultipleContexts) {
+ const char* code =
+ "(function() { return (42).toString(); })()";
+
+ {
+ // Run the code twice in the first context to initialize the call IC.
+ v8::HandleScope scope;
+ LocalContext context1;
+ ExpectString(code, "42");
+ ExpectString(code, "42");
+ }
+
+ {
+ // Change the Number.prototype in the second context and check
+ // that the right function gets called.
+ v8::HandleScope scope;
+ LocalContext context2;
+ CompileRun("Number.prototype.toString = function() { return \"not 42\"; }");
+ ExpectString(code, "not 42");
+ }
+}
+
+
+TEST(BooleanCheckMultipleContexts) {
+ const char* code =
+ "(function() { return true.toString(); })()";
+
+ {
+ // Run the code twice in the first context to initialize the call IC.
+ v8::HandleScope scope;
+ LocalContext context1;
+ ExpectString(code, "true");
+ ExpectString(code, "true");
+ }
+
+ {
+ // Change the Boolean.prototype in the second context and check
+ // that the right function gets called.
+ v8::HandleScope scope;
+ LocalContext context2;
+ CompileRun("Boolean.prototype.toString = function() { return \"\"; }");
+ ExpectString(code, "");
+ }
+}
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698