OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4621 "for(const x = 4, y of [1,2,3]) {}", | 4621 "for(const x = 4, y of [1,2,3]) {}", |
4622 "for(const x = 1, y = 2 in []) {}", | 4622 "for(const x = 1, y = 2 in []) {}", |
4623 "for(const x,y in []) {}", | 4623 "for(const x,y in []) {}", |
4624 "for(const x = 1, y = 2 of []) {}", | 4624 "for(const x = 1, y = 2 of []) {}", |
4625 "for(const x,y of []) {}", | 4625 "for(const x,y of []) {}", |
4626 NULL}; | 4626 NULL}; |
4627 RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0); | 4627 RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0); |
4628 } | 4628 } |
4629 | 4629 |
4630 | 4630 |
| 4631 TEST(InitializedDeclarationsInStrictForInError) { |
| 4632 const char* context_data[][2] = {{"'use strict';", ""}, |
| 4633 {"function foo(){ 'use strict';", "}"}, |
| 4634 {NULL, NULL}}; |
| 4635 |
| 4636 const char* data[] = { |
| 4637 "for (var i = 1 in {}) {}", |
| 4638 "for (var i = void 0 in [1, 2, 3]) {}", |
| 4639 "for (let i = 1 in {}) {}", |
| 4640 "for (let i = void 0 in [1, 2, 3]) {}", |
| 4641 "for (const i = 1 in {}) {}", |
| 4642 "for (const i = void 0 in [1, 2, 3]) {}", |
| 4643 NULL}; |
| 4644 RunParserSyncTest(context_data, data, kError); |
| 4645 } |
| 4646 |
| 4647 |
| 4648 TEST(InitializedDeclarationsInStrictForOfError) { |
| 4649 const char* context_data[][2] = {{"'use strict';", ""}, |
| 4650 {"function foo(){ 'use strict';", "}"}, |
| 4651 {NULL, NULL}}; |
| 4652 |
| 4653 const char* data[] = { |
| 4654 "for (var i = 1 of {}) {}", |
| 4655 "for (var i = void 0 of [1, 2, 3]) {}", |
| 4656 "for (let i = 1 of {}) {}", |
| 4657 "for (let i = void 0 of [1, 2, 3]) {}", |
| 4658 "for (const i = 1 of {}) {}", |
| 4659 "for (const i = void 0 of [1, 2, 3]) {}", |
| 4660 NULL}; |
| 4661 RunParserSyncTest(context_data, data, kError); |
| 4662 } |
| 4663 |
| 4664 |
| 4665 TEST(InitializedDeclarationsInSloppyForInError) { |
| 4666 const char* context_data[][2] = {{"", ""}, |
| 4667 {"function foo(){", "}"}, |
| 4668 {NULL, NULL}}; |
| 4669 |
| 4670 const char* data[] = { |
| 4671 "for (var i = 1 in {}) {}", |
| 4672 "for (var i = void 0 in [1, 2, 3]) {}", |
| 4673 NULL}; |
| 4674 // TODO(caitp): This should be an error in sloppy mode. |
| 4675 RunParserSyncTest(context_data, data, kSuccess); |
| 4676 } |
| 4677 |
| 4678 |
| 4679 TEST(InitializedDeclarationsInSloppyForOfError) { |
| 4680 const char* context_data[][2] = {{"", ""}, |
| 4681 {"function foo(){", "}"}, |
| 4682 {NULL, NULL}}; |
| 4683 |
| 4684 const char* data[] = { |
| 4685 "for (var i = 1 of {}) {}", |
| 4686 "for (var i = void 0 of [1, 2, 3]) {}", |
| 4687 NULL}; |
| 4688 RunParserSyncTest(context_data, data, kError); |
| 4689 } |
| 4690 |
| 4691 |
| 4692 TEST(ForInMultipleDeclarationsError) { |
| 4693 const char* context_data[][2] = {{"", ""}, |
| 4694 {"function foo(){", "}"}, |
| 4695 {"'use strict';", ""}, |
| 4696 {"function foo(){ 'use strict';", "}"}, |
| 4697 {NULL, NULL}}; |
| 4698 |
| 4699 const char* data[] = { |
| 4700 "for (var i, j in {}) {}", |
| 4701 "for (var i, j in [1, 2, 3]) {}", |
| 4702 "for (var i, j = 1 in {}) {}", |
| 4703 "for (var i, j = void 0 in [1, 2, 3]) {}", |
| 4704 |
| 4705 "for (let i, j in {}) {}", |
| 4706 "for (let i, j in [1, 2, 3]) {}", |
| 4707 "for (let i, j = 1 in {}) {}", |
| 4708 "for (let i, j = void 0 in [1, 2, 3]) {}", |
| 4709 |
| 4710 "for (const i, j in {}) {}", |
| 4711 "for (const i, j in [1, 2, 3]) {}", |
| 4712 "for (const i, j = 1 in {}) {}", |
| 4713 "for (const i, j = void 0 in [1, 2, 3]) {}", |
| 4714 NULL}; |
| 4715 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
| 4716 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
| 4717 arraysize(always_flags)); |
| 4718 } |
| 4719 |
| 4720 |
| 4721 TEST(ForOfMultipleDeclarationsError) { |
| 4722 const char* context_data[][2] = {{"", ""}, |
| 4723 {"function foo(){", "}"}, |
| 4724 {"'use strict';", ""}, |
| 4725 {"function foo(){ 'use strict';", "}"}, |
| 4726 {NULL, NULL}}; |
| 4727 |
| 4728 const char* data[] = { |
| 4729 "for (var i, j of {}) {}", |
| 4730 "for (var i, j of [1, 2, 3]) {}", |
| 4731 "for (var i, j = 1 of {}) {}", |
| 4732 "for (var i, j = void 0 of [1, 2, 3]) {}", |
| 4733 |
| 4734 "for (let i, j of {}) {}", |
| 4735 "for (let i, j of [1, 2, 3]) {}", |
| 4736 "for (let i, j = 1 of {}) {}", |
| 4737 "for (let i, j = void 0 of [1, 2, 3]) {}", |
| 4738 |
| 4739 "for (const i, j of {}) {}", |
| 4740 "for (const i, j of [1, 2, 3]) {}", |
| 4741 "for (const i, j = 1 of {}) {}", |
| 4742 "for (const i, j = void 0 of [1, 2, 3]) {}", |
| 4743 NULL}; |
| 4744 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
| 4745 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
| 4746 arraysize(always_flags)); |
| 4747 } |
| 4748 |
| 4749 |
| 4750 TEST(ForInNoDeclarationsError) { |
| 4751 const char* context_data[][2] = {{"", ""}, |
| 4752 {"function foo(){", "}"}, |
| 4753 {"'use strict';", ""}, |
| 4754 {"function foo(){ 'use strict';", "}"}, |
| 4755 {NULL, NULL}}; |
| 4756 |
| 4757 const char* data[] = { |
| 4758 "for (var in {}) {}", |
| 4759 "for (const in {}) {}", |
| 4760 NULL}; |
| 4761 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
| 4762 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
| 4763 arraysize(always_flags)); |
| 4764 } |
| 4765 |
| 4766 |
| 4767 TEST(ForOfNoDeclarationsError) { |
| 4768 const char* context_data[][2] = {{"", ""}, |
| 4769 {"function foo(){", "}"}, |
| 4770 {"'use strict';", ""}, |
| 4771 {"function foo(){ 'use strict';", "}"}, |
| 4772 {NULL, NULL}}; |
| 4773 |
| 4774 const char* data[] = { |
| 4775 "for (var of [1, 2, 3]) {}", |
| 4776 "for (const of [1, 2, 3]) {}", |
| 4777 NULL}; |
| 4778 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
| 4779 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
| 4780 arraysize(always_flags)); |
| 4781 } |
| 4782 |
| 4783 |
4631 TEST(InvalidUnicodeEscapes) { | 4784 TEST(InvalidUnicodeEscapes) { |
4632 const char* context_data[][2] = {{"", ""}, | 4785 const char* context_data[][2] = {{"", ""}, |
4633 {"'use strict';", ""}, | 4786 {"'use strict';", ""}, |
4634 {NULL, NULL}}; | 4787 {NULL, NULL}}; |
4635 const char* data[] = { | 4788 const char* data[] = { |
4636 "var foob\\u123r = 0;", | 4789 "var foob\\u123r = 0;", |
4637 "var \\u123roo = 0;", | 4790 "var \\u123roo = 0;", |
4638 "\"foob\\u123rr\"", | 4791 "\"foob\\u123rr\"", |
4639 // No escapes allowed in regexp flags | 4792 // No escapes allowed in regexp flags |
4640 "/regex/\\u0069g", | 4793 "/regex/\\u0069g", |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5797 v8::Script::Compile(v8_str(script3)); | 5950 v8::Script::Compile(v8_str(script3)); |
5798 CHECK(try_catch2.HasCaught()); | 5951 CHECK(try_catch2.HasCaught()); |
5799 v8::String::Utf8Value exception(try_catch2.Exception()); | 5952 v8::String::Utf8Value exception(try_catch2.Exception()); |
5800 CHECK_EQ(0, | 5953 CHECK_EQ(0, |
5801 strcmp( | 5954 strcmp( |
5802 "ReferenceError: In strong mode, using an undeclared global " | 5955 "ReferenceError: In strong mode, using an undeclared global " |
5803 "variable 'not_there3' is not allowed", | 5956 "variable 'not_there3' is not allowed", |
5804 *exception)); | 5957 *exception)); |
5805 } | 5958 } |
5806 } | 5959 } |
OLD | NEW |