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

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

Issue 1632213002: [Interpreter] Implement do expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 10 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
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.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 3807 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 Handle<Object> arg = handle(Smi::FromInt(i), isolate); 3818 Handle<Object> arg = handle(Smi::FromInt(i), isolate);
3819 Handle<Object> return_value = callable(arg).ToHandleChecked(); 3819 Handle<Object> return_value = callable(arg).ToHandleChecked();
3820 int expected = kBaseValue + i * (i + 1) / 2; 3820 int expected = kBaseValue + i * (i + 1) / 2;
3821 Handle<Smi> actual = Handle<Smi>::cast(return_value); 3821 Handle<Smi> actual = Handle<Smi>::cast(return_value);
3822 CHECK_EQ(actual->value(), expected); 3822 CHECK_EQ(actual->value(), expected);
3823 } 3823 }
3824 } 3824 }
3825 3825
3826 // TODO(oth): Test for..in with wide registers. 3826 // TODO(oth): Test for..in with wide registers.
3827 3827
3828 TEST(InterpreterDoExpression) {
3829 bool old_flag = FLAG_harmony_do_expressions;
3830 FLAG_harmony_do_expressions = true;
3831
3832 HandleAndZoneScope handles;
3833 i::Isolate* isolate = handles.main_isolate();
3834 Factory* factory = isolate->factory();
3835
3836 std::pair<const char*, Handle<Object>> do_expr[] = {
3837 {"var a = do {}; return a;", factory->undefined_value()},
3838 {"var a = do { var x = 100; }; return a;", factory->undefined_value()},
3839 {"var a = do { var x = 100; }; return a;", factory->undefined_value()},
3840 {"var a = do { var x = 100; x++; }; return a;",
3841 handle(Smi::FromInt(100), isolate)},
3842 {"var i = 0; for (; i < 5;) { i = do { if (i == 3) { break; }; i + 1; }};"
3843 "return i;",
3844 handle(Smi::FromInt(3), isolate)},
3845 };
3846
3847 for (size_t i = 0; i < arraysize(do_expr); i++) {
3848 std::string source(InterpreterTester::SourceForBody(do_expr[i].first));
3849 InterpreterTester tester(handles.main_isolate(), source.c_str());
3850 auto callable = tester.GetCallable<>();
3851
3852 Handle<i::Object> return_value = callable().ToHandleChecked();
3853 CHECK(return_value->SameValue(*do_expr[i].second));
3854 }
3855
3856 FLAG_harmony_do_expressions = old_flag;
3857 }
3858
3828 } // namespace interpreter 3859 } // namespace interpreter
3829 } // namespace internal 3860 } // namespace internal
3830 } // namespace v8 3861 } // namespace v8
OLDNEW
« no previous file with comments | « 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