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

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: Incorporate mstarzinger's comments on patch set 1. 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
3796 TEST(InterpreterClassLiterals) {
3797 HandleAndZoneScope handles;
3798 i::Isolate* isolate = handles.main_isolate();
3799 std::pair<const char*, Handle<Object>> examples[] = {
3800 {"class C {\n"
3801 " constructor(x) { this.x_ = x; }\n"
3802 " method() { return this.x_; }\n"
3803 "}\n"
3804 "return new C(99).method();",
3805 handle(Smi::FromInt(99), isolate)},
3806 {"class C {\n"
3807 " constructor(x) { this.x_ = x; }\n"
3808 " static static_method(x) { return x; }\n"
3809 "}\n"
3810 "return C.static_method(101);",
3811 handle(Smi::FromInt(101), isolate)},
3812 {"class C {\n"
3813 " get x() { return 102; }\n"
3814 "}\n"
3815 "return new C().x",
3816 handle(Smi::FromInt(102), isolate)},
3817 {"class C {\n"
3818 " static get x() { return 103; }\n"
3819 "}\n"
3820 "return C.x",
3821 handle(Smi::FromInt(103), isolate)},
3822 {"class C {\n"
3823 " constructor() { this.x_ = 0; }"
3824 " set x(value) { this.x_ = value; }\n"
3825 " get x() { return this.x_; }\n"
3826 "}\n"
3827 "var c = new C();"
3828 "c.x = 104;"
3829 "return c.x;",
3830 handle(Smi::FromInt(104), isolate)},
3831 {"var x = 0;"
3832 "class C {\n"
3833 " static set x(value) { x = value; }\n"
3834 " static get x() { return x; }\n"
3835 "}\n"
3836 "C.x = 105;"
3837 "return C.x;",
3838 handle(Smi::FromInt(105), isolate)},
3839 {"var method = 'f';"
3840 "class C {\n"
3841 " [method]() { return 106; }\n"
3842 "}\n"
3843 "return new C().f();",
3844 handle(Smi::FromInt(106), isolate)},
3845 };
3846
3847 for (size_t i = 0; i < arraysize(examples); ++i) {
3848 std::string source(InterpreterTester::SourceForBody(examples[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(*examples[i].second));
3854 }
3855 }
3856
3795 } // namespace interpreter 3857 } // namespace interpreter
3796 } // namespace internal 3858 } // namespace internal
3797 } // namespace v8 3859 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698