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

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

Issue 1509273005: Adds additional tests for bytecode graph builder (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added tests for ToName to interpreter. Created 5 years 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 | « test/cctest/compiler/test-run-bytecode-graph-builder.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/execution.h" 7 #include "src/execution.h"
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/interpreter/bytecode-array-builder.h" 9 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 3033 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 InterpreterTester tester(handles.main_isolate(), samples[i].first); 3044 InterpreterTester tester(handles.main_isolate(), samples[i].first);
3045 auto callable = tester.GetCallable<Handle<Object>>(); 3045 auto callable = tester.GetCallable<Handle<Object>>();
3046 Handle<Object> return_val = 3046 Handle<Object> return_val =
3047 callable(handle(Smi::FromInt(arg_value), handles.main_isolate())) 3047 callable(handle(Smi::FromInt(arg_value), handles.main_isolate()))
3048 .ToHandleChecked(); 3048 .ToHandleChecked();
3049 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), samples[i].second); 3049 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), samples[i].second);
3050 } 3050 }
3051 } 3051 }
3052 3052
3053 3053
3054 TEST(InterpreterToName) {
3055 HandleAndZoneScope handles;
3056 i::Isolate* isolate = handles.main_isolate();
3057 i::Factory* factory = isolate->factory();
3058
3059 std::pair<const char*, Handle<Object>> to_name_tests[] = {
3060 {"var a = 'val'; var obj = {[a] : 10}; return obj.val;",
3061 factory->NewNumberFromInt(10)},
3062 {"var a = 20; var obj = {[a] : 10}; return obj['20'];",
3063 factory->NewNumberFromInt(10)},
3064 {"var a = 20; var obj = {[a] : 10}; return obj[20];",
3065 factory->NewNumberFromInt(10)},
3066 {"var a = {val:23}; var obj = {[a] : 10}; return obj[a];",
3067 factory->NewNumberFromInt(10)},
3068 {"var a = {val:23}; var obj = {[a] : 10};\n"
3069 "return obj['[object Object]'];",
3070 factory->NewNumberFromInt(10)},
3071 {"var a = {toString : function() { return 'x'}};\n"
3072 "var obj = {[a] : 10};\n"
3073 "return obj.x;",
3074 factory->NewNumberFromInt(10)},
3075 {"var a = {valueOf : function() { return 'x'}};\n"
3076 "var obj = {[a] : 10};\n"
3077 "return obj.x;",
3078 factory->undefined_value()},
3079 {"var a = {[Symbol.toPrimitive] : function() { return 'x'}};\n"
3080 "var obj = {[a] : 10};\n"
3081 "return obj.x;",
3082 factory->NewNumberFromInt(10)},
3083 };
3084
3085 for (size_t i = 0; i < arraysize(to_name_tests); i++) {
3086 std::string source(
3087 InterpreterTester::SourceForBody(to_name_tests[i].first));
3088 InterpreterTester tester(handles.main_isolate(), source.c_str());
3089 auto callable = tester.GetCallable<>();
3090
3091 Handle<i::Object> return_value = callable().ToHandleChecked();
3092 CHECK(return_value->SameValue(*to_name_tests[i].second));
3093 }
3094 }
3095
3054 } // namespace interpreter 3096 } // namespace interpreter
3055 } // namespace internal 3097 } // namespace internal
3056 } // namespace v8 3098 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698