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 4477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4488 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 4488 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
4489 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4489 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
4490 } | 4490 } |
4491 } | 4491 } |
4492 | 4492 |
4493 | 4493 |
4494 TEST(IllegalRedeclaration) { | 4494 TEST(IllegalRedeclaration) { |
4495 InitializedHandleScope handle_scope; | 4495 InitializedHandleScope handle_scope; |
4496 BytecodeGeneratorHelper helper; | 4496 BytecodeGeneratorHelper helper; |
4497 | 4497 |
4498 ExpectedSnippet<const char*> snippets[] = { | 4498 CHECK_GE(MessageTemplate::kVarRedeclaration, 128); |
| 4499 // Must adapt bytecode if this changes. |
| 4500 |
| 4501 ExpectedSnippet<Handle<Object>, 2> snippets[] = { |
4499 {"const a = 1; { var a = 2; }", | 4502 {"const a = 1; { var a = 2; }", |
4500 3 * kPointerSize, | 4503 3 * kPointerSize, |
4501 1, | 4504 1, |
4502 14, | 4505 14, |
4503 { | 4506 { |
4504 B(LdaSmi8), U8(MessageTemplate::kVarRedeclaration), // | 4507 B(LdaConstant), U8(0), // |
4505 B(Star), R(1), // | 4508 B(Star), R(1), // |
4506 B(LdaConstant), U8(0), // | 4509 B(LdaConstant), U8(1), // |
4507 B(Star), R(2), // | 4510 B(Star), R(2), // |
4508 B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), // | 4511 B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), // |
4509 B(Throw), // | 4512 B(Throw), // |
4510 }, | 4513 }, |
4511 1, | 4514 2, |
4512 {"a"}}, | 4515 {helper.factory()->NewNumberFromInt(MessageTemplate::kVarRedeclaration), |
| 4516 helper.factory()->NewStringFromAsciiChecked("a")}}, |
4513 }; | 4517 }; |
4514 | 4518 |
4515 for (size_t i = 0; i < arraysize(snippets); i++) { | 4519 for (size_t i = 0; i < arraysize(snippets); i++) { |
4516 Handle<BytecodeArray> bytecode_array = | 4520 Handle<BytecodeArray> bytecode_array = |
4517 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 4521 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
4518 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4522 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
4519 } | 4523 } |
4520 } | 4524 } |
4521 | 4525 |
4522 | 4526 |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5479 for (size_t i = 0; i < arraysize(snippets); i++) { | 5483 for (size_t i = 0; i < arraysize(snippets); i++) { |
5480 Handle<BytecodeArray> bytecode_array = | 5484 Handle<BytecodeArray> bytecode_array = |
5481 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5485 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
5482 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5486 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
5483 } | 5487 } |
5484 } | 5488 } |
5485 | 5489 |
5486 } // namespace interpreter | 5490 } // namespace interpreter |
5487 } // namespace internal | 5491 } // namespace internal |
5488 } // namespace v8 | 5492 } // namespace v8 |
OLD | NEW |