Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 5d9985c4d5cfb0ae6dffde27ef6bfea3893f67db..5b4750a6a89886b1f84dcc5dfefd8b15e479d6bc 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -6537,6 +6537,108 @@ TEST(DestructuringNegativeTests) { |
| } |
| +TEST(DestructuringAssignmentPositiveTests) { |
| + i::FLAG_harmony_destructuring = true; |
| + i::FLAG_harmony_computed_property_names = true; |
| + |
| + const char* context_data[][2] = {{"'use strict'; let x, y, z; (", " = {});"}, |
| + {"var x, y, z; (", " = {});"}, |
|
arv (Not doing code reviews)
2015/06/04 20:08:04
Do you want to do for-in and for-of too?
caitp (gmail)
2015/06/05 18:37:14
Done.
|
| + {NULL, NULL}}; |
| + |
| + // clang-format off |
| + const char* data[] = { |
| + "x", |
| + "{ x : y }", |
| + "{ x : y = 1 }", |
| + "{ x }", |
| + "{ x, y, z }", |
| + "{ x = 1, y: z, z: y }", |
| + "{x = 42, y = 15}", |
| + "[x]", |
| + "[x = 1]", |
| + "[x,y,z]", |
| + "[x, y = 42, z]", |
| + "{ x : x, y : y }", |
| + "{ x : x = 1, y : y }", |
| + "{ x : x, y : y = 42 }", |
| + "[]", |
| + "{}", |
| + "[{x:x, y:y}, [,x,z,]]", |
| + "[{x:x = 1, y:y = 2}, [z = 3, z = 4, z = 5]]", |
| + "[x,,y]", |
| + "{42 : x}", |
| + "{42 : x = 42}", |
| + "{42e-2 : x}", |
| + "{42e-2 : x = 42}", |
| + "{'hi' : x}", |
| + "{'hi' : x = 42}", |
| + "{var: x}", |
| + "{var: x = 42}", |
| + "{[x] : z}", |
| + "{[1+1] : z}", |
| + "{[foo()] : z}", |
| + "[...x]", |
| + "[x,y,...z]", |
| + "[x,,...z]", |
| + NULL}; |
|
arv (Not doing code reviews)
2015/06/04 20:08:04
Needs more LHS expressions.
this.x
super.x
o['x']
caitp (gmail)
2015/06/05 18:37:14
I've added a bunch of these
|
| + // clang-format on |
| + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| + kAllowHarmonyComputedPropertyNames, |
| + kAllowHarmonyDestructuring}; |
| + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| + arraysize(always_flags)); |
| +} |
| + |
| + |
| +TEST(DestructuringAssignmentNegativeTests) { |
| + i::FLAG_harmony_destructuring = true; |
| + i::FLAG_harmony_computed_property_names = true; |
| + |
| + const char* context_data[][2] = {{"'use strict'; let x, y, z; (", " = {});"}, |
| + {"var x, y, z; (", " = {});"}, |
| + {NULL, NULL}}; |
| + |
| + // clang-format off |
| + const char* data[] = { |
| + "{ x : ++y }", |
| + "{ x : y * 2 }", |
| + "{ ...x }", |
| + "{ get x() {} }", |
| + "{ set x() {} }", |
| + "{ x: y() }", |
| + "{ this }", |
| + "{ x: this }", |
| + "{ x: this = 1 }", |
| + "{ super }", |
| + "{ x: super }", |
| + "{ x: super = 1 }", |
| + "{ new.target }", |
| + "{ x: new.target }", |
|
arv (Not doing code reviews)
2015/06/04 20:08:04
I think this is valid syntax inside a function but
caitp (gmail)
2015/06/04 20:54:15
IsValidSimpleAssignmentTarget returns false for `n
|
| + "{ x: new.target = 1 }", |
| + "[x--]", |
| + "[--x = 1]", |
| + "[x()]", |
| + "[this]", |
| + "[this = 1]", |
| + "[new.target]", |
| + "[new.target = 1]", |
| + "[super]", |
| + "[super = 1]", |
| + "[function f() {}]", |
| + "[50]", |
| + "{ x: 50 }", |
| + "['str']", |
| + "{ x: 'str' }", |
| + NULL}; |
| + // clang-format on |
| + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| + kAllowHarmonyComputedPropertyNames, |
| + kAllowHarmonyDestructuring}; |
| + RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| + arraysize(always_flags)); |
| +} |
| + |
| + |
| TEST(DestructuringDisallowPatternsInForVarIn) { |
| i::FLAG_harmony_destructuring = true; |
| static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |