| 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 6738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6749 // clang-format on | 6749 // clang-format on |
| 6750 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6750 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6751 arraysize(always_flags)); | 6751 arraysize(always_flags)); |
| 6752 } | 6752 } |
| 6753 | 6753 |
| 6754 | 6754 |
| 6755 TEST(DefaultParametersYieldInInitializers) { | 6755 TEST(DefaultParametersYieldInInitializers) { |
| 6756 // clang-format off | 6756 // clang-format off |
| 6757 const char* sloppy_function_context_data[][2] = { | 6757 const char* sloppy_function_context_data[][2] = { |
| 6758 {"(function f(", ") { });"}, | 6758 {"(function f(", ") { });"}, |
| 6759 // TODO(wingo): Add arrow functions. | |
| 6760 {NULL, NULL} | 6759 {NULL, NULL} |
| 6761 }; | 6760 }; |
| 6762 | 6761 |
| 6763 const char* strict_function_context_data[][2] = { | 6762 const char* strict_function_context_data[][2] = { |
| 6764 {"'use strong'; (function f(", ") { });"}, | 6763 {"'use strong'; (function f(", ") { });"}, |
| 6765 {"'use strict'; (function f(", ") { });"}, | 6764 {"'use strict'; (function f(", ") { });"}, |
| 6766 // TODO(wingo,conradw): These should also signal early errors. | 6765 {NULL, NULL} |
| 6767 // {"(function f(", ") {'use strong'; });"}, | 6766 }; |
| 6768 // {"(function f(", ") {'use strict'; });"}, | 6767 |
| 6769 // TODO(wingo): Add arrow functions. | 6768 const char* sloppy_arrow_context_data[][2] = { |
| 6769 {"((", ")=>{});"}, |
| 6770 {NULL, NULL} |
| 6771 }; |
| 6772 |
| 6773 const char* strict_arrow_context_data[][2] = { |
| 6774 {"'use strong'; ((", ")=>{});"}, |
| 6775 {"'use strict'; ((", ")=>{});"}, |
| 6770 {NULL, NULL} | 6776 {NULL, NULL} |
| 6771 }; | 6777 }; |
| 6772 | 6778 |
| 6773 const char* generator_context_data[][2] = { | 6779 const char* generator_context_data[][2] = { |
| 6774 {"'use strong'; (function *g(", ") { });"}, | 6780 {"'use strong'; (function *g(", ") { });"}, |
| 6775 {"'use strict'; (function *g(", ") { });"}, | 6781 {"'use strict'; (function *g(", ") { });"}, |
| 6776 // TODO(wingo,conradw): These should also signal early errors. | |
| 6777 // {"(function *g(", ") {'use strong'; });"}, | |
| 6778 // {"(function *g(", ") {'use strict'; });"}, | |
| 6779 {"(function *g(", ") { });"}, | 6782 {"(function *g(", ") { });"}, |
| 6780 {NULL, NULL} | 6783 {NULL, NULL} |
| 6781 }; | 6784 }; |
| 6782 | 6785 |
| 6783 const char* formal_parameter_data[] = { | 6786 const char* parameter_data[] = { |
| 6784 "x=yield", | 6787 "x=yield", |
| 6785 "x, y=yield", | 6788 "x, y=yield", |
| 6786 "{x=yield}", | 6789 "{x=yield}", |
| 6787 "[x=yield]", | 6790 "[x=yield]", |
| 6788 "{x}=yield", | |
| 6789 "[x]=yield", | |
| 6790 | 6791 |
| 6791 "x=(yield)", | 6792 "x=(yield)", |
| 6792 "x, y=(yield)", | 6793 "x, y=(yield)", |
| 6793 "{x=(yield)}", | 6794 "{x=(yield)}", |
| 6794 "[x=(yield)]", | 6795 "[x=(yield)]", |
| 6795 "{x}=(yield)", | |
| 6796 "[x]=(yield)", | |
| 6797 | 6796 |
| 6798 "x=f(yield)", | 6797 "x=f(yield)", |
| 6799 "x, y=f(yield)", | 6798 "x, y=f(yield)", |
| 6800 "{x=f(yield)}", | 6799 "{x=f(yield)}", |
| 6801 "[x=f(yield)]", | 6800 "[x=f(yield)]", |
| 6801 NULL |
| 6802 }; |
| 6803 |
| 6804 // TODO(wingo): These aren't really destructuring assignment patterns; we're |
| 6805 // just splitting them for now until the parser gets support for arrow |
| 6806 // function arguments that look like destructuring assignments. When that |
| 6807 // happens we should unify destructuring_assignment_data and parameter_data. |
| 6808 const char* destructuring_assignment_data[] = { |
| 6809 "{x}=yield", |
| 6810 "[x]=yield", |
| 6811 |
| 6812 "{x}=(yield)", |
| 6813 "[x]=(yield)", |
| 6814 |
| 6802 "{x}=f(yield)", | 6815 "{x}=f(yield)", |
| 6803 "[x]=f(yield)", | 6816 "[x]=f(yield)", |
| 6804 NULL | 6817 NULL |
| 6805 }; | 6818 }; |
| 6806 | 6819 |
| 6807 // clang-format on | 6820 // clang-format on |
| 6808 static const ParserFlag always_flags[] = { | 6821 static const ParserFlag always_flags[] = { |
| 6809 kAllowHarmonyDestructuring, kAllowHarmonyDefaultParameters, | 6822 kAllowHarmonyDestructuring, kAllowHarmonyDefaultParameters, |
| 6810 kAllowHarmonyArrowFunctions, kAllowStrongMode}; | 6823 kAllowHarmonyArrowFunctions, kAllowStrongMode}; |
| 6811 RunParserSyncTest(sloppy_function_context_data, formal_parameter_data, | 6824 |
| 6825 RunParserSyncTest(sloppy_function_context_data, parameter_data, kSuccess, |
| 6826 NULL, 0, always_flags, arraysize(always_flags)); |
| 6827 RunParserSyncTest(sloppy_function_context_data, destructuring_assignment_data, |
| 6812 kSuccess, NULL, 0, always_flags, arraysize(always_flags)); | 6828 kSuccess, NULL, 0, always_flags, arraysize(always_flags)); |
| 6813 RunParserSyncTest(strict_function_context_data, formal_parameter_data, kError, | 6829 RunParserSyncTest(sloppy_arrow_context_data, parameter_data, kSuccess, NULL, |
| 6814 NULL, 0, always_flags, arraysize(always_flags)); | |
| 6815 RunParserSyncTest(generator_context_data, formal_parameter_data, kError, NULL, | |
| 6816 0, always_flags, arraysize(always_flags)); | 6830 0, always_flags, arraysize(always_flags)); |
| 6831 // TODO(wingo): Will change to kSuccess when destructuring assignment lands. |
| 6832 RunParserSyncTest(sloppy_arrow_context_data, destructuring_assignment_data, |
| 6833 kError, NULL, 0, always_flags, arraysize(always_flags)); |
| 6834 |
| 6835 RunParserSyncTest(strict_function_context_data, parameter_data, kError, NULL, |
| 6836 0, always_flags, arraysize(always_flags)); |
| 6837 RunParserSyncTest(strict_function_context_data, destructuring_assignment_data, |
| 6838 kError, NULL, 0, always_flags, arraysize(always_flags)); |
| 6839 RunParserSyncTest(strict_arrow_context_data, parameter_data, kError, NULL, 0, |
| 6840 always_flags, arraysize(always_flags)); |
| 6841 RunParserSyncTest(strict_arrow_context_data, destructuring_assignment_data, |
| 6842 kError, NULL, 0, always_flags, arraysize(always_flags)); |
| 6843 |
| 6844 RunParserSyncTest(generator_context_data, parameter_data, kError, NULL, 0, |
| 6845 always_flags, arraysize(always_flags)); |
| 6846 RunParserSyncTest(generator_context_data, destructuring_assignment_data, |
| 6847 kError, NULL, 0, always_flags, arraysize(always_flags)); |
| 6817 } | 6848 } |
| 6818 | 6849 |
| 6819 | 6850 |
| 6820 TEST(SpreadArray) { | 6851 TEST(SpreadArray) { |
| 6821 i::FLAG_harmony_spread_arrays = true; | 6852 i::FLAG_harmony_spread_arrays = true; |
| 6822 | 6853 |
| 6823 const char* context_data[][2] = { | 6854 const char* context_data[][2] = { |
| 6824 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; | 6855 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; |
| 6825 | 6856 |
| 6826 // clang-format off | 6857 // clang-format off |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7070 NULL}; | 7101 NULL}; |
| 7071 | 7102 |
| 7072 static const ParserFlag always_flags[] = { | 7103 static const ParserFlag always_flags[] = { |
| 7073 kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters, | 7104 kAllowHarmonyArrowFunctions, kAllowHarmonyDefaultParameters, |
| 7074 kAllowHarmonyDestructuring, kAllowHarmonyRestParameters, | 7105 kAllowHarmonyDestructuring, kAllowHarmonyRestParameters, |
| 7075 kAllowHarmonySloppy, kAllowStrongMode | 7106 kAllowHarmonySloppy, kAllowStrongMode |
| 7076 }; | 7107 }; |
| 7077 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7108 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 7078 arraysize(always_flags)); | 7109 arraysize(always_flags)); |
| 7079 } | 7110 } |
| OLD | NEW |