Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index bd3247e044a738947d859880a7a84ccb708bacbc..8a0248020e35183c1115dc36e071fa7e744885dc 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -1381,8 +1381,9 @@ enum ParserFlag { |
kAllowHarmonySloppy, |
kAllowHarmonyUnicode, |
kAllowHarmonyComputedPropertyNames, |
- kAllowStrongMode, |
- kAllowHarmonySpreadCalls |
+ kAllowHarmonySpreadCalls, |
+ kAllowHarmonyDestructuring, |
+ kAllowStrongMode |
}; |
@@ -1411,6 +1412,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser, |
parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); |
parser->set_allow_harmony_computed_property_names( |
flags.Contains(kAllowHarmonyComputedPropertyNames)); |
+ parser->set_allow_harmony_destructuring( |
+ flags.Contains(kAllowHarmonyDestructuring)); |
parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); |
} |
@@ -6344,3 +6347,39 @@ TEST(StrongModeFreeVariablesNotDeclared) { |
*exception)); |
} |
} |
+ |
+ |
+TEST(DestructuringPositiveTests) { |
+ i::FLAG_harmony_destructuring = true; |
+ |
+ const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
+ {"var ", " = {};"}, |
+ {"'use strict'; const ", " = {};"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = {"a", "{ x : y }", "[a]", "[a,b,c]", "{ x : x, y : y }", |
rossberg
2015/04/27 17:20:24
Add [], {}, and {x}, and a couple of nested cases
arv (Not doing code reviews)
2015/04/27 17:56:55
Nit: Don't let `git cl format` bully you. These th
arv (Not doing code reviews)
2015/04/27 17:56:55
How about?
- nested patterns
- array elision
- re
Dmitry Lomov (no reviews)
2015/04/28 10:15:49
No! All hail 'git cl format'! Our Blessed Format-L
Dmitry Lomov (no reviews)
2015/04/28 10:15:49
Done.
Dmitry Lomov (no reviews)
2015/04/28 10:15:49
Added everything I support yet. Rest, initializers
|
+ NULL}; |
+ static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
+TEST(DestructuringNegativeTests) { |
+ i::FLAG_harmony_destructuring = true; |
+ |
+ const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
+ {"var ", " = {};"}, |
+ {"'use strict'; const ", " = {};"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "a++", "++a", "delete a", "void a", "typeof a", "--a", "+a", "-a", "~a", |
+ "!a", "{ x : y++ }", "[a++]", "(x => y)", "a[i]", "a()", "a.b", "new a", |
arv (Not doing code reviews)
2015/04/27 17:56:55
also "() => x"
Dmitry Lomov (no reviews)
2015/04/28 10:15:49
Done.
|
+ "a + a", "a - a", "a * a", "a / a", "a == a", "a != a", "a > a", "a < a", |
+ "a <<< a", "a >>> a", "function a() {}", "a`bcd`", "x => x", "this", |
+ "null", "true", "false", "1", "'abc'", "class {}", NULL}; |
arv (Not doing code reviews)
2015/04/27 17:56:55
How about some keywords, eval/arguments and strict
Dmitry Lomov (no reviews)
2015/04/28 10:15:49
Done.
|
+ static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
+ arraysize(always_flags)); |
+} |