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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/x87/builtins-x87.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(rmcilroy): Remove this define after this flag is turned on globally 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 for (size_t i = 0; i < arraysize(switch_ops); i++) { 2878 for (size_t i = 0; i < arraysize(switch_ops); i++) {
2879 std::string source(InterpreterTester::SourceForBody(switch_ops[i].first)); 2879 std::string source(InterpreterTester::SourceForBody(switch_ops[i].first));
2880 InterpreterTester tester(handles.main_isolate(), source.c_str()); 2880 InterpreterTester tester(handles.main_isolate(), source.c_str());
2881 auto callable = tester.GetCallable<>(); 2881 auto callable = tester.GetCallable<>();
2882 2882
2883 Handle<i::Object> return_value = callable().ToHandleChecked(); 2883 Handle<i::Object> return_value = callable().ToHandleChecked();
2884 CHECK(return_value->SameValue(*switch_ops[i].second)); 2884 CHECK(return_value->SameValue(*switch_ops[i].second));
2885 } 2885 }
2886 } 2886 }
2887 2887
2888
2889 TEST(InterpreterSloppyThis) {
2890 HandleAndZoneScope handles;
2891 i::Isolate* isolate = handles.main_isolate();
2892 i::Factory* factory = isolate->factory();
2893
2894 std::pair<const char*, Handle<Object>> sloppy_this[] = {
2895 std::make_pair("var global_val = 100;\n"
2896 "function f() { return this.global_val; }\n",
2897 handle(Smi::FromInt(100), isolate)),
2898 std::make_pair("var global_val = 110;\n"
2899 "function g() { return this.global_val; };"
2900 "function f() { return g(); }\n",
2901 handle(Smi::FromInt(110), isolate)),
2902 std::make_pair("var global_val = 110;\n"
2903 "function g() { return this.global_val };"
2904 "function f() { 'use strict'; return g(); }\n",
2905 handle(Smi::FromInt(110), isolate)),
2906 std::make_pair("function f() { 'use strict'; return this; }\n",
2907 factory->undefined_value()),
2908 std::make_pair("function g() { 'use strict'; return this; };"
2909 "function f() { return g(); }\n",
2910 factory->undefined_value()),
2911 };
2912
2913 for (size_t i = 0; i < arraysize(sloppy_this); i++) {
2914 InterpreterTester tester(handles.main_isolate(), sloppy_this[i].first);
2915 auto callable = tester.GetCallable<>();
2916
2917 Handle<i::Object> return_value = callable().ToHandleChecked();
2918 CHECK(return_value->SameValue(*sloppy_this[i].second));
2919 }
2920 }
2921
2888 } // namespace interpreter 2922 } // namespace interpreter
2889 } // namespace internal 2923 } // namespace internal
2890 } // namespace v8 2924 } // namespace v8
OLDNEW
« 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