OLD | NEW |
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 <fstream> | 5 #include <fstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/bytecode-array-iterator.h" | 10 #include "src/interpreter/bytecode-array-iterator.h" |
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 InitializedIgnitionHandleScope scope; | 2093 InitializedIgnitionHandleScope scope; |
2094 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 2094 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
2095 ConstantPoolType::kString); | 2095 ConstantPoolType::kString); |
2096 const char* snippets[] = { | 2096 const char* snippets[] = { |
2097 "debugger;", | 2097 "debugger;", |
2098 }; | 2098 }; |
2099 | 2099 |
2100 CHECK_EQ(BuildActual(printer, snippets), LoadGolden("DoDebugger.golden")); | 2100 CHECK_EQ(BuildActual(printer, snippets), LoadGolden("DoDebugger.golden")); |
2101 } | 2101 } |
2102 | 2102 |
2103 // TODO(rmcilroy): Update expectations after switch to | |
2104 // Runtime::kDefineDataPropertyInLiteral. | |
2105 TEST(ClassDeclarations) { | 2103 TEST(ClassDeclarations) { |
2106 InitializedIgnitionHandleScope scope; | 2104 InitializedIgnitionHandleScope scope; |
2107 BytecodeExpectationsPrinter printer(CcTest::isolate(), | 2105 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
2108 ConstantPoolType::kMixed); | 2106 ConstantPoolType::kMixed); |
2109 const char* snippets[] = { | 2107 const char* snippets[] = { |
2110 "class Person {\n" | 2108 "class Person {\n" |
2111 " constructor(name) { this.name = name; }\n" | 2109 " constructor(name) { this.name = name; }\n" |
2112 " speak() { console.log(this.name + ' is speaking.'); }\n" | 2110 " speak() { console.log(this.name + ' is speaking.'); }\n" |
2113 "}", | 2111 "}", |
2114 | 2112 |
(...skipping 11 matching lines...) Expand all Loading... |
2126 | 2124 |
2127 "var count = 0;\n" | 2125 "var count = 0;\n" |
2128 "class C { constructor() { count++; }}\n" | 2126 "class C { constructor() { count++; }}\n" |
2129 "return new C();\n", | 2127 "return new C();\n", |
2130 }; | 2128 }; |
2131 | 2129 |
2132 CHECK_EQ(BuildActual(printer, snippets), | 2130 CHECK_EQ(BuildActual(printer, snippets), |
2133 LoadGolden("ClassDeclarations.golden")); | 2131 LoadGolden("ClassDeclarations.golden")); |
2134 } | 2132 } |
2135 | 2133 |
2136 // TODO(oth): Add tests for super keyword. | 2134 TEST(ClassAndSuperClass) { |
| 2135 InitializedIgnitionHandleScope scope; |
| 2136 BytecodeExpectationsPrinter printer(CcTest::isolate(), |
| 2137 ConstantPoolType::kMixed); |
| 2138 printer.set_wrap(false); |
| 2139 printer.set_test_function_name("test"); |
| 2140 const char* snippets[] = { |
| 2141 "var test;\n" |
| 2142 "(function() {\n" |
| 2143 " class A {\n" |
| 2144 " method() { return 2; }\n" |
| 2145 " }\n" |
| 2146 " class B extends A {\n" |
| 2147 " method() { return super.method() + 1; }\n" |
| 2148 " }\n" |
| 2149 " test = new B().method;\n" |
| 2150 " test();\n" |
| 2151 "})();\n", |
| 2152 |
| 2153 "var test;\n" |
| 2154 "(function() {\n" |
| 2155 " class A {\n" |
| 2156 " get x() { return 1; }\n" |
| 2157 " set x(val) { return; }\n" |
| 2158 " }\n" |
| 2159 " class B extends A {\n" |
| 2160 " method() { super.x = 2; return super.x; }\n" |
| 2161 " }\n" |
| 2162 " test = new B().method;\n" |
| 2163 " test();\n" |
| 2164 "})();\n", |
| 2165 |
| 2166 "var test;\n" |
| 2167 "(function() {\n" |
| 2168 " class A {\n" |
| 2169 " constructor(x) { this.x_ = x; }\n" |
| 2170 " }\n" |
| 2171 " class B extends A {\n" |
| 2172 " constructor() { super(1); this.y_ = 2; }\n" |
| 2173 " }\n" |
| 2174 " test = new B().constructor;\n" |
| 2175 "})();\n", |
| 2176 |
| 2177 "var test;\n" |
| 2178 "(function() {\n" |
| 2179 " class A {\n" |
| 2180 " constructor() { this.x_ = 1; }\n" |
| 2181 " }\n" |
| 2182 " class B extends A {\n" |
| 2183 " constructor() { super(); this.y_ = 2; }\n" |
| 2184 " }\n" |
| 2185 " test = new B().constructor;\n" |
| 2186 "})();\n", |
| 2187 }; |
| 2188 |
| 2189 CHECK_EQ(BuildActual(printer, snippets), |
| 2190 LoadGolden("ClassAndSuperClass.golden")); |
| 2191 } |
2137 | 2192 |
2138 } // namespace interpreter | 2193 } // namespace interpreter |
2139 } // namespace internal | 2194 } // namespace internal |
2140 } // namespace v8 | 2195 } // namespace v8 |
OLD | NEW |