| 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/interpreter/bytecode-array-iterator.h" | 9 #include "src/interpreter/bytecode-array-iterator.h" |
| 10 #include "src/interpreter/bytecode-generator.h" | 10 #include "src/interpreter/bytecode-generator.h" |
| (...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 " constructor() { super(); this.y_ = 2; }\n" | 2160 " constructor() { super(); this.y_ = 2; }\n" |
| 2161 " }\n" | 2161 " }\n" |
| 2162 " test = new B().constructor;\n" | 2162 " test = new B().constructor;\n" |
| 2163 "})();\n", | 2163 "})();\n", |
| 2164 }; | 2164 }; |
| 2165 | 2165 |
| 2166 CHECK(CompareTexts(BuildActual(printer, snippets), | 2166 CHECK(CompareTexts(BuildActual(printer, snippets), |
| 2167 LoadGolden("ClassAndSuperClass.golden"))); | 2167 LoadGolden("ClassAndSuperClass.golden"))); |
| 2168 } | 2168 } |
| 2169 | 2169 |
| 2170 TEST(ClassFields) { |
| 2171 bool old_flag = FLAG_harmony_class_fields; |
| 2172 FLAG_harmony_class_fields = true; |
| 2173 |
| 2174 InitializedIgnitionHandleScope scope; |
| 2175 BytecodeExpectationsPrinter printer(CcTest::isolate()); |
| 2176 const char* snippets[] = { |
| 2177 "return new class {\n" |
| 2178 " 'a' = 0;\n" |
| 2179 " ['b'+'c'] = 1;\n" |
| 2180 " static d = 2;\n" |
| 2181 "}\n", |
| 2182 |
| 2183 "return new class extends class {} {\n" |
| 2184 " constructor(){ super() }\n" |
| 2185 " 'a' = 0;\n" |
| 2186 " ['b'+'c'] = 1;\n" |
| 2187 " static d = 2;\n" |
| 2188 "}\n", |
| 2189 }; |
| 2190 |
| 2191 CHECK(CompareTexts(BuildActual(printer, snippets), |
| 2192 LoadGolden("ClassFields.golden"))); |
| 2193 |
| 2194 FLAG_harmony_class_fields = old_flag; |
| 2195 } |
| 2196 |
| 2170 TEST(Generators) { | 2197 TEST(Generators) { |
| 2171 InitializedIgnitionHandleScope scope; | 2198 InitializedIgnitionHandleScope scope; |
| 2172 BytecodeExpectationsPrinter printer(CcTest::isolate()); | 2199 BytecodeExpectationsPrinter printer(CcTest::isolate()); |
| 2173 printer.set_wrap(false); | 2200 printer.set_wrap(false); |
| 2174 printer.set_test_function_name("f"); | 2201 printer.set_test_function_name("f"); |
| 2175 | 2202 |
| 2176 const char* snippets[] = { | 2203 const char* snippets[] = { |
| 2177 "function* f() { }\n" | 2204 "function* f() { }\n" |
| 2178 "f();\n", | 2205 "f();\n", |
| 2179 | 2206 |
| 2180 "function* f() { yield 42 }\n" | 2207 "function* f() { yield 42 }\n" |
| 2181 "f();\n", | 2208 "f();\n", |
| 2182 | 2209 |
| 2183 "function* f() { for (let x of [42]) yield x }\n" | 2210 "function* f() { for (let x of [42]) yield x }\n" |
| 2184 "f();\n", | 2211 "f();\n", |
| 2185 }; | 2212 }; |
| 2186 | 2213 |
| 2187 CHECK(CompareTexts(BuildActual(printer, snippets), | 2214 CHECK(CompareTexts(BuildActual(printer, snippets), |
| 2188 LoadGolden("Generators.golden"))); | 2215 LoadGolden("Generators.golden"))); |
| 2189 } | 2216 } |
| 2190 | 2217 |
| 2191 } // namespace interpreter | 2218 } // namespace interpreter |
| 2192 } // namespace internal | 2219 } // namespace internal |
| 2193 } // namespace v8 | 2220 } // namespace v8 |
| OLD | NEW |