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

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

Issue 1417053004: [Interpreter] Add conditional expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_prologue
Patch Set: Created 5 years, 2 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 unified diff | Download patch
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 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2257 }; 2257 };
2258 2258
2259 InterpreterTester tester(handles.main_isolate(), create_args[i].first); 2259 InterpreterTester tester(handles.main_isolate(), create_args[i].first);
2260 auto callable = 2260 auto callable =
2261 tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>(); 2261 tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>();
2262 Handle<Object> return_val = 2262 Handle<Object> return_val =
2263 callable(args[0], args[1], args[2]).ToHandleChecked(); 2263 callable(args[0], args[1], args[2]).ToHandleChecked();
2264 CHECK(return_val->SameValue(*args[create_args[i].second])); 2264 CHECK(return_val->SameValue(*args[create_args[i].second]));
2265 } 2265 }
2266 } 2266 }
2267
2268
2269 TEST(InterpreterConditional) {
2270 HandleAndZoneScope handles;
2271 i::Isolate* isolate = handles.main_isolate();
2272
2273 std::pair<const char*, Handle<Object>> conditional[8] = {
2274 std::make_pair("return true ? 2 : 3;",
2275 handle(Smi::FromInt(2), isolate)),
2276 std::make_pair("return false ? 2 : 3;",
2277 handle(Smi::FromInt(3), isolate)),
2278 std::make_pair("var a = 1; return a ? 20 : 30;",
2279 handle(Smi::FromInt(20), isolate)),
2280 std::make_pair("var a = 1; return a ? 20 : 30;",
2281 handle(Smi::FromInt(20), isolate)),
2282 std::make_pair("var a = 'string'; return a ? 20 : 30;",
2283 handle(Smi::FromInt(20), isolate)),
2284 std::make_pair("var a = undefined; return a ? 20 : 30;",
2285 handle(Smi::FromInt(30), isolate)),
2286 std::make_pair("return 1 ? 2 ? 3 : 4 : 5;",
2287 handle(Smi::FromInt(3), isolate)),
2288 std::make_pair("return 0 ? 2 ? 3 : 4 : 5;",
2289 handle(Smi::FromInt(5), isolate)),
2290 };
2291
2292 for (size_t i = 0; i < arraysize(conditional); i++) {
2293 std::string source(InterpreterTester::SourceForBody(conditional[i].first));
2294 InterpreterTester tester(handles.main_isolate(), source.c_str());
2295 auto callable = tester.GetCallable<>();
2296
2297 Handle<i::Object> return_value = callable().ToHandleChecked();
2298 CHECK(return_value->SameValue(*conditional[i].second));
2299 }
2300 }
OLDNEW
« src/interpreter/bytecode-generator.cc ('K') | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698