Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index a3ee6bea045ad4c9a788922a1ed833f44b9c291e..c4f44c8826f0fa744d9ec18c6d947f5ac16d0fab 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -1277,7 +1277,7 @@ enum ParserFlag { |
| kAllowHarmonyRestrictiveGenerators, |
| kAllowHarmonyTrailingCommas, |
| kAllowHarmonyClassFields, |
| - kAllowHarmonyObjectSpread, |
| + kAllowHarmonyObjectRestSpread, |
| }; |
| enum ParserSyncTestResult { |
| @@ -1293,7 +1293,8 @@ void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { |
| flags.Contains(kAllowHarmonyRestrictiveGenerators); |
| i::FLAG_harmony_trailing_commas = flags.Contains(kAllowHarmonyTrailingCommas); |
| i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields); |
| - i::FLAG_harmony_object_spread = flags.Contains(kAllowHarmonyObjectSpread); |
| + i::FLAG_harmony_object_rest_spread = |
| + flags.Contains(kAllowHarmonyObjectRestSpread); |
| } |
| void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
| @@ -1306,8 +1307,8 @@ void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
| flags.Contains(kAllowHarmonyTrailingCommas)); |
| parser->set_allow_harmony_class_fields( |
| flags.Contains(kAllowHarmonyClassFields)); |
| - parser->set_allow_harmony_object_spread( |
| - flags.Contains(kAllowHarmonyObjectSpread)); |
| + parser->set_allow_harmony_object_rest_spread( |
| + flags.Contains(kAllowHarmonyObjectRestSpread)); |
| } |
| void TestParserSyncWithFlags(i::Handle<i::String> source, |
| @@ -6539,65 +6540,26 @@ TEST(ObjectSpreadPositiveTests) { |
| "{ ...new Foo()}", |
| NULL}; |
| - static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; |
| + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
| arraysize(flags)); |
| } |
| TEST(ObjectSpreadNegativeTests) { |
| - { |
| - const char* context_data[][2] = {{"x = ", ""}, |
| - {"'use strict'; x = ", ""}, |
| - {NULL, NULL}}; |
| - |
| - // clang-format off |
| - const char* data[] = { |
| - "{ ...var z = y}", |
| - "{ ...var}", |
| - "{ ...foo bar}", |
| - NULL}; |
| - |
| - static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; |
| - RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| - arraysize(flags)); |
| - } |
| - |
| - // Destructuring tests |
| - { |
| - const char* context_data[][2] = { |
| - {"var ", " = {};"}, |
| - {"( ", " = {});"}, |
| - {"'use strict'; const ", " = {};"}, |
| - {"function f(", ") {}"}, |
| - {"function f(argument1, ", ") {}"}, |
| - {"var f = (", ") => {};"}, |
| - {"var f = (argument1,", ") => {};"}, |
| - {"try {} catch(", ") {}"}, |
| - {NULL, NULL}}; |
| + const char* context_data[][2] = {{"x = ", ""}, |
| + {"'use strict'; x = ", ""}, |
| + {NULL, NULL}}; |
| - // clang-format off |
| - const char* data[] = { |
| - "{ ...y }", |
| - "{ a: 1, ...y }", |
| - "{ b: 1, ...y }", |
| - "{ y, ...y}", |
| - "{ ...z = y}", |
| - "{ ...y, y }", |
| - "{ ...y, ...y}", |
| - "{ a: 1, ...y, b: 1}", |
| - "{ ...y, b: 1}", |
| - "{ ...1}", |
| - "{ ...null}", |
| - "{ ...undefined}", |
| - "{ ...unknown}", |
| - "{ ...var z = y}", |
| - "({ ...z = {})", |
| - NULL}; |
| + // clang-format off |
| + const char* data[] = { |
| + "{ ...var z = y}", |
| + "{ ...var}", |
| + "{ ...foo bar}", |
| + NULL}; |
| - static const ParserFlag flags[] = {kAllowHarmonyObjectSpread}; |
| - RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| - arraysize(flags)); |
| - } |
| + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| + arraysize(flags)); |
| } |
| TEST(DestructuringPositiveTests) { |
| @@ -6615,7 +6577,9 @@ TEST(DestructuringPositiveTests) { |
| const char* data[] = { |
| "a", |
| "{ x : y }", |
| + "{ x : y, ...z }", |
|
adamk
2017/01/12 22:43:08
Rather than interleaving the new tests and always
gsathya
2017/01/17 19:28:59
Done.
|
| "{ x : y = 1 }", |
| + "{ x : y = 1, ...z }", |
| "{ get, set }", |
| "{ get = 1, set = 2 }", |
| "[a]", |
| @@ -6623,38 +6587,56 @@ TEST(DestructuringPositiveTests) { |
| "[a,b,c]", |
| "[a, b = 42, c]", |
| "{ x : x, y : y }", |
| + "{ x : x, y : y, ...z }", |
| "{ x : x = 1, y : y }", |
| + "{ x : x = 1, y : y, ...z }", |
| "{ x : x, y : y = 42 }", |
| + "{ x : x, y : y = 42, ...z }", |
| "[]", |
| "{}", |
| "[{x:x, y:y}, [a,b,c]]", |
| + "[{x:x, y:y, ...z}, [a,b,c]]", |
| "[{x:x = 1, y:y = 2}, [a = 3, b = 4, c = 5]]", |
| - "{x}", |
| + "[{x:x = 1, y:y = 2, ...z}, [a = 3, b = 4, c = 5]]", |
| + "{...x}", |
| + "{...{ x = 5} }", |
| "{x, y}", |
| + "{x, ...y}", |
| "{x = 42, y = 15}", |
| + "{x = 42, y = 15, ...z}", |
| "[a,,b]", |
| "{42 : x}", |
| "{42 : x = 42}", |
| + "{42 : x = 42, ...y}", |
| "{42e-2 : x}", |
| "{42e-2 : x = 42}", |
| "{x : y, x : z}", |
| "{'hi' : x}", |
| + "{'hi' : x, ...z}", |
| "{'hi' : x = 42}", |
| + "{'hi' : x = 42, ...z}", |
| "{var: x}", |
| "{var: x = 42}", |
| + "{var: x = 42, ...z}", |
| "{[x] : z}", |
| + "{[x] : z, ...y}", |
| "{[1+1] : z}", |
| + "{[1+1] : z, ...x}", |
| "{[foo()] : z}", |
| "{}", |
| "[...rest]", |
| "[a,b,...rest]", |
| "[a,,...rest]", |
| "{ __proto__: x, __proto__: y}", |
| + "{ __proto__: x, __proto__: y, ...z}", |
| "{arguments: x}", |
| + "{arguments: x, ...z}", |
| "{eval: x}", |
| NULL}; |
| // clang-format on |
| - RunParserSyncTest(context_data, data, kSuccess); |
| + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
| + arraysize(flags)); |
| // v8:5201 |
| { |
| @@ -6675,10 +6657,15 @@ TEST(DestructuringPositiveTests) { |
| "{x: eval}", |
| "{arguments = false}", |
| "{eval = false}", |
| + "{...arguments}", |
| + "{...eval}", |
| + "{z, ...z,}", |
| NULL |
| }; |
| // clang-format on |
| - RunParserSyncTest(sloppy_context_data, data, kSuccess); |
| + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| + RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, flags, |
| + arraysize(flags)); |
| } |
| } |
| @@ -6699,10 +6686,13 @@ TEST(DestructuringNegativeTests) { |
| // clang-format off |
| const char* data[] = { |
| "a++", |
| + "...a++", |
| "++a", |
| + "...++a", |
| "delete a", |
| "void a", |
| "typeof a", |
| + "...typeof a", |
| "--a", |
| "+a", |
| "-a", |
| @@ -6710,7 +6700,9 @@ TEST(DestructuringNegativeTests) { |
| "!a", |
| "{ x : y++ }", |
| "[a++]", |
| + "...[a++]", |
| "(x => y)", |
| + "...(x => y)", |
| "a[i]", "a()", |
| "a.b", |
| "new a", |
| @@ -6758,17 +6750,33 @@ TEST(DestructuringNegativeTests) { |
| "[...z = 1]", |
| "[x, y, ...[z] = [1]]", |
| "[...[z] = [1]]", |
| + "{ ...x, }", |
| + "{ ...x, y }", |
| + "{ y, ...x, y }", |
| + "{ ...x, ...y }", |
| + "{ ...x, ...x }", |
| + "{ ...x, ...x = {} }", |
| + "{ ...x, ...x = ...x }", |
| + "{ ...x, ...x = ...{ x } }", |
| + "{ ,, ...x }", |
| "{ x : 3 }", |
| "{ x : 'foo' }", |
| "{ x : /foo/ }", |
| "{ x : `foo` }", |
| "{ get a() {} }", |
| + "{ ...get a() {} }", |
| "{ set a() {} }", |
| + "{ ...set a() {} }", |
| "{ method() {} }", |
| + "{ ...method() {} }", |
| + "{ ...function() {} }", |
| "{ *method() {} }", |
| + "{ ...*method() {} }", |
| NULL}; |
| // clang-format on |
| - RunParserSyncTest(context_data, data, kError); |
| + static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| + arraysize(flags)); |
| } |
| { // All modes. |