| 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 6812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6823 TEST(DestructuringAssignmentPositiveTests) { | 6823 TEST(DestructuringAssignmentPositiveTests) { |
| 6824 const char* context_data[][2] = { | 6824 const char* context_data[][2] = { |
| 6825 {"'use strict'; let x, y, z; (", " = {});"}, | 6825 {"'use strict'; let x, y, z; (", " = {});"}, |
| 6826 {"var x, y, z; (", " = {});"}, | 6826 {"var x, y, z; (", " = {});"}, |
| 6827 {"'use strict'; let x, y, z; for (x in ", " = {});"}, | 6827 {"'use strict'; let x, y, z; for (x in ", " = {});"}, |
| 6828 {"'use strict'; let x, y, z; for (x of ", " = {});"}, | 6828 {"'use strict'; let x, y, z; for (x of ", " = {});"}, |
| 6829 {"var x, y, z; for (x in ", " = {});"}, | 6829 {"var x, y, z; for (x in ", " = {});"}, |
| 6830 {"var x, y, z; for (x of ", " = {});"}, | 6830 {"var x, y, z; for (x of ", " = {});"}, |
| 6831 {NULL, NULL}}; | 6831 {NULL, NULL}}; |
| 6832 | 6832 |
| 6833 const char* mixed_assignments_context_data[][2] = { |
| 6834 {"'use strict'; let x, y, z; (", " = z = {});"}, |
| 6835 {"var x, y, z; (", " = z = {});"}, |
| 6836 {"'use strict'; let x, y, z; (x = ", " = z = {});"}, |
| 6837 {"var x, y, z; (x = ", " = z = {});"}, |
| 6838 {"'use strict'; let x, y, z; for (x in ", " = z = {});"}, |
| 6839 {"'use strict'; let x, y, z; for (x in x = ", " = z = {});"}, |
| 6840 {"'use strict'; let x, y, z; for (x of ", " = z = {});"}, |
| 6841 {"'use strict'; let x, y, z; for (x of x = ", " = z = {});"}, |
| 6842 {"var x, y, z; for (x in ", " = z = {});"}, |
| 6843 {"var x, y, z; for (x in x = ", " = z = {});"}, |
| 6844 {"var x, y, z; for (x of ", " = z = {});"}, |
| 6845 {"var x, y, z; for (x of x = ", " = z = {});"}, |
| 6846 }; |
| 6847 |
| 6833 // clang-format off | 6848 // clang-format off |
| 6834 const char* data[] = { | 6849 const char* data[] = { |
| 6835 "x", | 6850 "x", |
| 6836 | 6851 |
| 6837 "{ x : y }", | 6852 "{ x : y }", |
| 6838 "{ x : foo().y }", | 6853 "{ x : foo().y }", |
| 6839 "{ x : foo()[y] }", | 6854 "{ x : foo()[y] }", |
| 6840 "{ x : y.z }", | 6855 "{ x : y.z }", |
| 6841 "{ x : y[z] }", | 6856 "{ x : y[z] }", |
| 6842 "{ x : { y } }", | 6857 "{ x : { y } }", |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6938 "{[foo()] : (z)}", | 6953 "{[foo()] : (z)}", |
| 6939 "{[foo()] : foo().bar}", | 6954 "{[foo()] : foo().bar}", |
| 6940 "{[foo()] : foo()['bar']}", | 6955 "{[foo()] : foo()['bar']}", |
| 6941 "{[foo()] : this.bar}", | 6956 "{[foo()] : this.bar}", |
| 6942 "{[foo()] : this['bar']}", | 6957 "{[foo()] : this['bar']}", |
| 6943 "{[foo()] : 'foo'.bar}", | 6958 "{[foo()] : 'foo'.bar}", |
| 6944 "{[foo()] : 'foo'['bar']}", | 6959 "{[foo()] : 'foo'['bar']}", |
| 6945 "[...x]", | 6960 "[...x]", |
| 6946 "[x,y,...z]", | 6961 "[x,y,...z]", |
| 6947 "[x,,...z]", | 6962 "[x,,...z]", |
| 6948 "{ x: y } = z", | 6963 "{ x: y }", |
| 6949 "[x, y] = z", | 6964 "[x, y]", |
| 6950 "{ x: y } = { z }", | 6965 "{ x: y } = { z }", |
| 6951 "[x, y] = { z }", | 6966 "[x, y] = { z }", |
| 6952 "{ x: y } = [ z ]", | 6967 "{ x: y } = [ z ]", |
| 6953 "[x, y] = [ z ]", | 6968 "[x, y] = [ z ]", |
| 6954 "[((x, y) => z).x]", | 6969 "[((x, y) => z).x]", |
| 6955 "{x: ((y, z) => z).x}", | 6970 "{x: ((y, z) => z).x}", |
| 6956 "[((x, y) => z)['x']]", | 6971 "[((x, y) => z)['x']]", |
| 6957 "{x: ((y, z) => z)['x']}", | 6972 "{x: ((y, z) => z)['x']}", |
| 6958 | 6973 |
| 6959 "{x: { y = 10 } }", | 6974 "{x: { y = 10 } }", |
| 6960 "[(({ x } = { x: 1 }) => x).a]", | 6975 "[(({ x } = { x: 1 }) => x).a]", |
| 6961 NULL}; | 6976 NULL}; |
| 6962 // clang-format on | 6977 // clang-format on |
| 6963 static const ParserFlag always_flags[] = { | 6978 static const ParserFlag always_flags[] = { |
| 6964 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, | 6979 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, |
| 6965 kAllowHarmonyDefaultParameters}; | 6980 kAllowHarmonyDefaultParameters}; |
| 6966 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6981 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6967 arraysize(always_flags)); | 6982 arraysize(always_flags)); |
| 6968 | 6983 |
| 6984 RunParserSyncTest(mixed_assignments_context_data, data, kSuccess, NULL, 0, |
| 6985 always_flags, arraysize(always_flags)); |
| 6986 |
| 6969 const char* empty_context_data[][2] = { | 6987 const char* empty_context_data[][2] = { |
| 6970 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; | 6988 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; |
| 6971 | 6989 |
| 6972 // CoverInitializedName ambiguity handling in various contexts | 6990 // CoverInitializedName ambiguity handling in various contexts |
| 6973 const char* ambiguity_data[] = { | 6991 const char* ambiguity_data[] = { |
| 6974 "var foo = { x = 10 } = {};", | 6992 "var foo = { x = 10 } = {};", |
| 6975 "var foo = { q } = { x = 10 } = {};", | 6993 "var foo = { q } = { x = 10 } = {};", |
| 6976 "var foo; foo = { x = 10 } = {};", | 6994 "var foo; foo = { x = 10 } = {};", |
| 6977 "var foo; foo = { q } = { x = 10 } = {};", | 6995 "var foo; foo = { q } = { x = 10 } = {};", |
| 6978 "var x; ({ x = 10 } = {});", | 6996 "var x; ({ x = 10 } = {});", |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7748 "var publ\\u0069c = 1;", | 7766 "var publ\\u0069c = 1;", |
| 7749 "var { publ\\u0069c } = {};", | 7767 "var { publ\\u0069c } = {};", |
| 7750 NULL}; | 7768 NULL}; |
| 7751 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, | 7769 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, |
| 7752 always_flags, arraysize(always_flags)); | 7770 always_flags, arraysize(always_flags)); |
| 7753 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7771 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
| 7754 always_flags, arraysize(always_flags)); | 7772 always_flags, arraysize(always_flags)); |
| 7755 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7773 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
| 7756 always_flags, arraysize(always_flags)); | 7774 always_flags, arraysize(always_flags)); |
| 7757 } | 7775 } |
| OLD | NEW |