| 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, "");
|
| + }
|
| +}
|
|
|