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

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

Issue 1666943003: [interpreter] Support for ES6 class literals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Another tweak to cctest.status. 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
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 3774 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 for (size_t i = 0; i < arraysize(with_stmt); i++) { 3785 for (size_t i = 0; i < arraysize(with_stmt); i++) {
3786 std::string source(InterpreterTester::SourceForBody(with_stmt[i].first)); 3786 std::string source(InterpreterTester::SourceForBody(with_stmt[i].first));
3787 InterpreterTester tester(handles.main_isolate(), source.c_str()); 3787 InterpreterTester tester(handles.main_isolate(), source.c_str());
3788 auto callable = tester.GetCallable<>(); 3788 auto callable = tester.GetCallable<>();
3789 3789
3790 Handle<i::Object> return_value = callable().ToHandleChecked(); 3790 Handle<i::Object> return_value = callable().ToHandleChecked();
3791 CHECK(return_value->SameValue(*with_stmt[i].second)); 3791 CHECK(return_value->SameValue(*with_stmt[i].second));
3792 } 3792 }
3793 } 3793 }
3794 3794
3795 TEST(InterpreterClassLiterals) {
3796 HandleAndZoneScope handles;
3797 i::Isolate* isolate = handles.main_isolate();
3798 std::pair<const char*, Handle<Object>> examples[] = {
3799 {"class C {\n"
3800 " constructor(x) { this.x_ = x; }\n"
3801 " method() { return this.x_; }\n"
3802 "}\n"
3803 "return new C(99).method();",
3804 handle(Smi::FromInt(99), isolate)},
3805 {"class C {\n"
3806 " constructor(x) { this.x_ = x; }\n"
3807 " static static_method(x) { return x; }\n"
3808 "}\n"
3809 "return C.static_method(101);",
3810 handle(Smi::FromInt(101), isolate)},
3811 {"class C {\n"
3812 " get x() { return 102; }\n"
3813 "}\n"
3814 "return new C().x",
3815 handle(Smi::FromInt(102), isolate)},
3816 {"class C {\n"
3817 " static get x() { return 103; }\n"
3818 "}\n"
3819 "return C.x",
3820 handle(Smi::FromInt(103), isolate)},
3821 {"class C {\n"
3822 " constructor() { this.x_ = 0; }"
3823 " set x(value) { this.x_ = value; }\n"
3824 " get x() { return this.x_; }\n"
3825 "}\n"
3826 "var c = new C();"
3827 "c.x = 104;"
3828 "return c.x;",
3829 handle(Smi::FromInt(104), isolate)},
3830 {"var x = 0;"
3831 "class C {\n"
3832 " static set x(value) { x = value; }\n"
3833 " static get x() { return x; }\n"
3834 "}\n"
3835 "C.x = 105;"
3836 "return C.x;",
3837 handle(Smi::FromInt(105), isolate)},
3838 {"var method = 'f';"
3839 "class C {\n"
3840 " [method]() { return 106; }\n"
3841 "}\n"
3842 "return new C().f();",
3843 handle(Smi::FromInt(106), isolate)},
3844 };
3845
3846 for (size_t i = 0; i < arraysize(examples); ++i) {
3847 std::string source(InterpreterTester::SourceForBody(examples[i].first));
3848 InterpreterTester tester(handles.main_isolate(), source.c_str());
3849 auto callable = tester.GetCallable<>();
3850
3851 Handle<i::Object> return_value = callable().ToHandleChecked();
3852 CHECK(return_value->SameValue(*examples[i].second));
3853 }
3854 }
3855
3795 } // namespace interpreter 3856 } // namespace interpreter
3796 } // namespace internal 3857 } // namespace internal
3797 } // namespace v8 3858 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698