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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 "yield++;", | 1808 "yield++;", |
1809 "yield: 34", | 1809 "yield: 34", |
1810 "function yield(yield) { yield: yield (yield + yield(0)); }", | 1810 "function yield(yield) { yield: yield (yield + yield(0)); }", |
1811 "({ yield: 1 })", | 1811 "({ yield: 1 })", |
1812 "({ get yield() { 1 } })", | 1812 "({ get yield() { 1 } })", |
1813 "yield(100)", | 1813 "yield(100)", |
1814 "yield[100]", | 1814 "yield[100]", |
1815 NULL | 1815 NULL |
1816 }; | 1816 }; |
1817 | 1817 |
1818 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; | 1818 RunParserSyncTest(context_data, statement_data, kSuccess); |
1819 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | |
1820 always_flags, ARRAY_SIZE(always_flags)); | |
1821 } | 1819 } |
1822 | 1820 |
1823 | 1821 |
1824 TEST(NoErrorsYieldSloppyGeneratorsEnabled) { | 1822 TEST(NoErrorsYieldSloppyGeneratorsEnabled) { |
1825 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a | 1823 // In sloppy mode, it's okay to use "yield" as identifier, *except* inside a |
1826 // generator (see next test). | 1824 // generator (see next test). |
1827 const char* context_data[][2] = { | 1825 const char* context_data[][2] = { |
1828 { "", "" }, | 1826 { "", "" }, |
1829 { "function not_gen() {", "}" }, | 1827 { "function not_gen() {", "}" }, |
1830 { "function * gen() { function not_gen() {", "} }" }, | 1828 { "function * gen() { function not_gen() {", "} }" }, |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3081 "([], a) => {}", | 3079 "([], a) => {}", |
3082 "(a = b) => {}", | 3080 "(a = b) => {}", |
3083 "(a = b, c) => {}", | 3081 "(a = b, c) => {}", |
3084 "(a, b = c) => {}", | 3082 "(a, b = c) => {}", |
3085 "(foo ? bar : baz) => {}", | 3083 "(foo ? bar : baz) => {}", |
3086 "(a, foo ? bar : baz) => {}", | 3084 "(a, foo ? bar : baz) => {}", |
3087 "(foo ? bar : baz, a) => {}", | 3085 "(foo ? bar : baz, a) => {}", |
3088 NULL | 3086 NULL |
3089 }; | 3087 }; |
3090 | 3088 |
3091 RunParserSyncTest(context_data, statement_data, kError); | 3089 // The test is quite slow, so run it with a reduced set of flags. |
| 3090 static const ParserFlag flags[] = { |
| 3091 kAllowLazy, kAllowHarmonyScoping, kAllowGenerators |
| 3092 }; |
| 3093 static const ParserFlag always_flags[] = { kAllowArrowFunctions }; |
| 3094 RunParserSyncTest(context_data, statement_data, kError, flags, |
| 3095 ARRAY_SIZE(flags), always_flags, ARRAY_SIZE(always_flags)); |
3092 } | 3096 } |
3093 | 3097 |
3094 | 3098 |
3095 TEST(NoErrorsArrowFunctions) { | 3099 TEST(NoErrorsArrowFunctions) { |
3096 // Tests that parser and preparser accept valid arrow functions syntax. | 3100 // Tests that parser and preparser accept valid arrow functions syntax. |
3097 const char* context_data[][2] = { | 3101 const char* context_data[][2] = { |
3098 {"", ";"}, | 3102 {"", ";"}, |
3099 {"bar ? (", ") : baz;"}, | 3103 {"bar ? (", ") : baz;"}, |
3100 {"bar ? baz : (", ");"}, | 3104 {"bar ? baz : (", ");"}, |
3101 {"bar, ", ";"}, | 3105 {"bar, ", ";"}, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3137 | 3141 |
3138 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) | 3142 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) |
3139 "foo ? bar : baz => {}", | 3143 "foo ? bar : baz => {}", |
3140 NULL | 3144 NULL |
3141 }; | 3145 }; |
3142 | 3146 |
3143 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; | 3147 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
3144 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 3148 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
3145 always_flags, ARRAY_SIZE(always_flags)); | 3149 always_flags, ARRAY_SIZE(always_flags)); |
3146 } | 3150 } |
OLD | NEW |