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[] = { | |
oth
2016/03/15 14:54:09
Can you add a few more here - InterpreterClassAndS
rmcilroy
2016/03/16 14:16:41
Done.
| |
2141 "var test;\n" | |
2142 "(function() {\n" | |
2143 " class A {\n" | |
2144 " method(x) { return 2; }\n" | |
2145 " }\n" | |
2146 " class B extends A {\n" | |
2147 " method(x) { 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 " constructor() { this.x_ = 1; }\n" | |
2157 " }\n" | |
2158 " class B extends A {\n" | |
2159 " constructor() { super(); this.y_ = 2; }\n" | |
2160 " }\n" | |
2161 " test = new B().constructor;\n" | |
2162 "})();\n", | |
2163 }; | |
2164 | |
2165 CHECK_EQ(BuildActual(printer, snippets), | |
2166 LoadGolden("ClassAndSuperClass.golden")); | |
2167 } | |
2137 | 2168 |
2138 } // namespace interpreter | 2169 } // namespace interpreter |
2139 } // namespace internal | 2170 } // namespace internal |
2140 } // namespace v8 | 2171 } // namespace v8 |
OLD | NEW |