Chromium Code Reviews| 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, nullptr, 0, nullptr, 0); | |
|
marja
2015/04/08 10:05:47
You don't need the params after 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, nullptr, 0, nullptr, 0); | |
| 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, nullptr, 0, nullptr, 0); | |
| 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, nullptr, 0, nullptr, 0); | |
| 4689 } | |
| 4690 | |
| 4691 | |
|
marja
2015/04/08 10:05:47
Hmm, none of the added tests exercises the code pa
caitp (gmail)
2015/04/08 12:44:36
done
| |
| 4631 TEST(InvalidUnicodeEscapes) { | 4692 TEST(InvalidUnicodeEscapes) { |
| 4632 const char* context_data[][2] = {{"", ""}, | 4693 const char* context_data[][2] = {{"", ""}, |
| 4633 {"'use strict';", ""}, | 4694 {"'use strict';", ""}, |
| 4634 {NULL, NULL}}; | 4695 {NULL, NULL}}; |
| 4635 const char* data[] = { | 4696 const char* data[] = { |
| 4636 "var foob\\u123r = 0;", | 4697 "var foob\\u123r = 0;", |
| 4637 "var \\u123roo = 0;", | 4698 "var \\u123roo = 0;", |
| 4638 "\"foob\\u123rr\"", | 4699 "\"foob\\u123rr\"", |
| 4639 // No escapes allowed in regexp flags | 4700 // No escapes allowed in regexp flags |
| 4640 "/regex/\\u0069g", | 4701 "/regex/\\u0069g", |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5797 v8::Script::Compile(v8_str(script3)); | 5858 v8::Script::Compile(v8_str(script3)); |
| 5798 CHECK(try_catch2.HasCaught()); | 5859 CHECK(try_catch2.HasCaught()); |
| 5799 v8::String::Utf8Value exception(try_catch2.Exception()); | 5860 v8::String::Utf8Value exception(try_catch2.Exception()); |
| 5800 CHECK_EQ(0, | 5861 CHECK_EQ(0, |
| 5801 strcmp( | 5862 strcmp( |
| 5802 "ReferenceError: In strong mode, using an undeclared global " | 5863 "ReferenceError: In strong mode, using an undeclared global " |
| 5803 "variable 'not_there3' is not allowed", | 5864 "variable 'not_there3' is not allowed", |
| 5804 *exception)); | 5865 *exception)); |
| 5805 } | 5866 } |
| 5806 } | 5867 } |
| OLD | NEW |