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

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

Issue 1410113008: [Interpreter] Add test for sloppy mode receiver replacement. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase to include Toon's sloppy receiver change Created 5 years, 1 month 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/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 49df43ce9582d9c647046fa66ea2ffa370128d2b..12a4b4de735ef386b2842f2741debc6d674094a3 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -2885,6 +2885,40 @@ TEST(InterpreterSwitch) {
}
}
+
+TEST(InterpreterSloppyThis) {
+ HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
+ i::Factory* factory = isolate->factory();
+
+ std::pair<const char*, Handle<Object>> sloppy_this[] = {
+ std::make_pair("var global_val = 100;\n"
+ "function f() { return this.global_val; }\n",
+ handle(Smi::FromInt(100), isolate)),
+ std::make_pair("var global_val = 110;\n"
+ "function g() { return this.global_val; };"
+ "function f() { return g(); }\n",
+ handle(Smi::FromInt(110), isolate)),
+ std::make_pair("var global_val = 110;\n"
+ "function g() { return this.global_val };"
+ "function f() { 'use strict'; return g(); }\n",
+ handle(Smi::FromInt(110), isolate)),
+ std::make_pair("function f() { 'use strict'; return this; }\n",
+ factory->undefined_value()),
+ std::make_pair("function g() { 'use strict'; return this; };"
+ "function f() { return g(); }\n",
+ factory->undefined_value()),
+ };
+
+ for (size_t i = 0; i < arraysize(sloppy_this); i++) {
+ InterpreterTester tester(handles.main_isolate(), sloppy_this[i].first);
+ auto callable = tester.GetCallable<>();
+
+ Handle<i::Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*sloppy_this[i].second));
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « src/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698