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 // TODO(rmcilroy): Remove this define after this flag is turned on globally | 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 4441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4452 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 4452 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
4453 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4453 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
4454 } | 4454 } |
4455 } | 4455 } |
4456 | 4456 |
4457 | 4457 |
4458 TEST(IllegalRedeclaration) { | 4458 TEST(IllegalRedeclaration) { |
4459 InitializedHandleScope handle_scope; | 4459 InitializedHandleScope handle_scope; |
4460 BytecodeGeneratorHelper helper; | 4460 BytecodeGeneratorHelper helper; |
4461 | 4461 |
4462 ExpectedSnippet<const char*> snippets[] = { | 4462 CHECK_GE(MessageTemplate::kVarRedeclaration, 128); |
| 4463 // Must adapt bytecode if this changes. |
| 4464 |
| 4465 ExpectedSnippet<Handle<Object>, 2> snippets[] = { |
4463 {"const a = 1; { var a = 2; }", | 4466 {"const a = 1; { var a = 2; }", |
4464 3 * kPointerSize, | 4467 3 * kPointerSize, |
4465 1, | 4468 1, |
4466 14, | 4469 14, |
4467 { | 4470 { |
4468 B(LdaSmi8), U8(MessageTemplate::kVarRedeclaration), // | 4471 B(LdaConstant), U8(0), // |
4469 B(Star), R(1), // | 4472 B(Star), R(1), // |
4470 B(LdaConstant), U8(0), // | 4473 B(LdaConstant), U8(1), // |
4471 B(Star), R(2), // | 4474 B(Star), R(2), // |
4472 B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), // | 4475 B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), // |
4473 B(Throw), // | 4476 B(Throw), // |
4474 }, | 4477 }, |
4475 1, | 4478 2, |
4476 {"a"}}, | 4479 {helper.factory()->NewNumberFromInt(MessageTemplate::kVarRedeclaration), |
| 4480 helper.factory()->NewStringFromAsciiChecked("a")}}, |
4477 }; | 4481 }; |
4478 | 4482 |
4479 for (size_t i = 0; i < arraysize(snippets); i++) { | 4483 for (size_t i = 0; i < arraysize(snippets); i++) { |
4480 Handle<BytecodeArray> bytecode_array = | 4484 Handle<BytecodeArray> bytecode_array = |
4481 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 4485 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
4482 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4486 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
4483 } | 4487 } |
4484 } | 4488 } |
4485 | 4489 |
4486 | 4490 |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5224 for (size_t i = 0; i < arraysize(snippets); i++) { | 5228 for (size_t i = 0; i < arraysize(snippets); i++) { |
5225 Handle<BytecodeArray> bytecode_array = | 5229 Handle<BytecodeArray> bytecode_array = |
5226 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5230 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
5227 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5231 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
5228 } | 5232 } |
5229 } | 5233 } |
5230 | 5234 |
5231 } // namespace interpreter | 5235 } // namespace interpreter |
5232 } // namespace internal | 5236 } // namespace internal |
5233 } // namespace v8 | 5237 } // namespace v8 |
OLD | NEW |