Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 7a624cb0bf38f99a55ade2350f72af62986ed960..935e273ca10220dd118f5d784894badb315b06b2 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -1388,7 +1388,8 @@ enum ParserFlag { |
| kAllowHarmonySloppy, |
| kAllowHarmonyUnicode, |
| kAllowHarmonyComputedPropertyNames, |
| - kAllowStrongMode |
| + kAllowStrongMode, |
| + kAllowHarmonySpreadCalls |
| }; |
| @@ -4982,6 +4983,60 @@ TEST(RestParametersDuplicateEvalArguments) { |
| } |
| +TEST(SpreadCall) { |
| + const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"}, |
| + {"function fn() {} fn(", ");"}, |
| + {NULL, NULL}}; |
| + |
| + const char* data[] = { |
| + "...([1, 2, 3])", |
| + "...'123', ...'456'", |
|
rossberg
2015/02/24 16:22:47
Have some more tests with spreads interleaved with
|
| + "...new Set([1, 2, 3]), 4", |
| + "1, ...[2, 3], 4", |
| + "...Array(...[1,2,3,4])", |
| + "...NaN", |
| + NULL}; |
| + |
| + static const ParserFlag always_flags[] = {kAllowHarmonySpreadCalls}; |
| + |
| + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| + arraysize(always_flags)); |
| +} |
| + |
| + |
| +TEST(SpreadCallErrors) { |
| + const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"}, |
| + {"function fn() {} fn(", ");"}, |
| + {NULL, NULL}}; |
| + |
| + const char* data[] = { |
| + "(...[1, 2, 3])", |
| + "......[1,2,3]", |
| + NULL}; |
| + |
| + static const ParserFlag always_flags[] = {kAllowHarmonySpreadCalls}; |
| + |
| + RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| + arraysize(always_flags)); |
| +} |
| + |
| + |
| +TEST(BadRestSpread) { |
| + const char* context_data[][2] = {{"function fn() { 'use strict';", "} fn();"}, |
| + {"function fn() { ", "} fn();" }, |
| + {NULL, NULL}}; |
| + const char* data[] = { |
| + "return ...[1,2,3];", |
| + "var ...x = [1,2,3];", |
| + "var [...x,] = [1,2,3];", |
| + "var [...x, y] = [1,2,3];", |
| + "var {...x} = [1,2,3];", |
| + "var { x } = {x: ...[1,2,3]}", |
| + NULL}; |
| + RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0); |
| +} |
| + |
| + |
| TEST(LexicalScopingSloppyMode) { |
| const char* context_data[][2] = { |
| {"", ""}, |