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 6810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6821 | 6821 |
6822 | 6822 |
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 {"var x, y, z; for (", " in {});"}, | |
6832 {"var x, y, z; for (", " of {});"}, | |
6833 {"'use strict'; var x, y, z; for (", " in {});"}, | |
6834 {"'use strict'; var x, y, z; for (", " of {});"}, | |
6835 {NULL, NULL}}; | |
6836 | |
6837 const char* mixed_assignments_context_data[][2] = { | |
6838 {"'use strict'; let x, y, z; (", " = z = {});"}, | |
6839 {"var x, y, z; (", " = z = {});"}, | |
6840 {"'use strict'; let x, y, z; (x = ", " = z = {});"}, | |
6841 {"var x, y, z; (x = ", " = z = {});"}, | |
6842 {"'use strict'; let x, y, z; for (x in ", " = z = {});"}, | |
6843 {"'use strict'; let x, y, z; for (x in x = ", " = z = {});"}, | |
6844 {"'use strict'; let x, y, z; for (x of ", " = z = {});"}, | |
6845 {"'use strict'; let x, y, z; for (x of x = ", " = z = {});"}, | |
6846 {"var x, y, z; for (x in ", " = z = {});"}, | |
6847 {"var x, y, z; for (x in x = ", " = z = {});"}, | |
6848 {"var x, y, z; for (x of ", " = z = {});"}, | |
6849 {"var x, y, z; for (x of x = ", " = z = {});"}, | |
6850 {NULL, NULL}}; | 6831 {NULL, NULL}}; |
6851 | 6832 |
6852 // clang-format off | 6833 // clang-format off |
6853 const char* data[] = { | 6834 const char* data[] = { |
6854 "x", | 6835 "x", |
6855 | 6836 |
6856 "{ x : y }", | 6837 "{ x : y }", |
6857 "{ x : foo().y }", | 6838 "{ x : foo().y }", |
6858 "{ x : foo()[y] }", | 6839 "{ x : foo()[y] }", |
6859 "{ x : y.z }", | 6840 "{ x : y.z }", |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6913 "[ { x : y = 10 } = {} ]", | 6894 "[ { x : y = 10 } = {} ]", |
6914 "[ { x : foo().y = 10 } = {} ]", | 6895 "[ { x : foo().y = 10 } = {} ]", |
6915 "[ { x : foo()[y] = 10 } = {} ]", | 6896 "[ { x : foo()[y] = 10 } = {} ]", |
6916 "[ { x : x.y = 10 } = {} ]", | 6897 "[ { x : x.y = 10 } = {} ]", |
6917 "[ { x : x[y] = 10 } = {} ]", | 6898 "[ { x : x[y] = 10 } = {} ]", |
6918 "[ [ x = 10 ] = {} ]", | 6899 "[ [ x = 10 ] = {} ]", |
6919 "[ [ foo().x = 10 ] = {} ]", | 6900 "[ [ foo().x = 10 ] = {} ]", |
6920 "[ [ foo()[x] = 10 ] = {} ]", | 6901 "[ [ foo()[x] = 10 ] = {} ]", |
6921 "[ [ x.y = 10 ] = {} ]", | 6902 "[ [ x.y = 10 ] = {} ]", |
6922 "[ [ x[y] = 10 ] = {} ]", | 6903 "[ [ x[y] = 10 ] = {} ]", |
| 6904 |
| 6905 "{ x : y }", |
6923 "{ x : y = 1 }", | 6906 "{ x : y = 1 }", |
6924 "{ x }", | 6907 "{ x }", |
6925 "{ x, y, z }", | 6908 "{ x, y, z }", |
6926 "{ x = 1, y: z, z: y }", | 6909 "{ x = 1, y: z, z: y }", |
6927 "{x = 42, y = 15}", | 6910 "{x = 42, y = 15}", |
6928 "[x]", | 6911 "[x]", |
6929 "[x = 1]", | 6912 "[x = 1]", |
6930 "[x,y,z]", | 6913 "[x,y,z]", |
6931 "[x, y = 42, z]", | 6914 "[x, y = 42, z]", |
6932 "{ x : x, y : y }", | 6915 "{ x : x, y : y }", |
(...skipping 22 matching lines...) Expand all Loading... |
6955 "{[foo()] : (z)}", | 6938 "{[foo()] : (z)}", |
6956 "{[foo()] : foo().bar}", | 6939 "{[foo()] : foo().bar}", |
6957 "{[foo()] : foo()['bar']}", | 6940 "{[foo()] : foo()['bar']}", |
6958 "{[foo()] : this.bar}", | 6941 "{[foo()] : this.bar}", |
6959 "{[foo()] : this['bar']}", | 6942 "{[foo()] : this['bar']}", |
6960 "{[foo()] : 'foo'.bar}", | 6943 "{[foo()] : 'foo'.bar}", |
6961 "{[foo()] : 'foo'['bar']}", | 6944 "{[foo()] : 'foo'['bar']}", |
6962 "[...x]", | 6945 "[...x]", |
6963 "[x,y,...z]", | 6946 "[x,y,...z]", |
6964 "[x,,...z]", | 6947 "[x,,...z]", |
6965 "{ x: y }", | 6948 "{ x: y } = z", |
6966 "[x, y]", | 6949 "[x, y] = z", |
| 6950 "{ x: y } = { z }", |
| 6951 "[x, y] = { z }", |
| 6952 "{ x: y } = [ z ]", |
| 6953 "[x, y] = [ z ]", |
6967 "[((x, y) => z).x]", | 6954 "[((x, y) => z).x]", |
6968 "{x: ((y, z) => z).x}", | 6955 "{x: ((y, z) => z).x}", |
6969 "[((x, y) => z)['x']]", | 6956 "[((x, y) => z)['x']]", |
6970 "{x: ((y, z) => z)['x']}", | 6957 "{x: ((y, z) => z)['x']}", |
6971 | 6958 |
6972 "{x: { y = 10 } }", | 6959 "{x: { y = 10 } }", |
6973 "[(({ x } = { x: 1 }) => x).a]", | 6960 "[(({ x } = { x: 1 }) => x).a]", |
6974 NULL}; | 6961 NULL}; |
6975 // clang-format on | 6962 // clang-format on |
6976 static const ParserFlag always_flags[] = { | 6963 static const ParserFlag always_flags[] = { |
6977 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, | 6964 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, |
6978 kAllowHarmonyDefaultParameters}; | 6965 kAllowHarmonyDefaultParameters}; |
6979 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6966 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
6980 arraysize(always_flags)); | 6967 arraysize(always_flags)); |
6981 | 6968 |
6982 RunParserSyncTest(mixed_assignments_context_data, data, kSuccess, NULL, 0, | |
6983 always_flags, arraysize(always_flags)); | |
6984 | |
6985 const char* empty_context_data[][2] = { | 6969 const char* empty_context_data[][2] = { |
6986 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; | 6970 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; |
6987 | 6971 |
6988 // CoverInitializedName ambiguity handling in various contexts | 6972 // CoverInitializedName ambiguity handling in various contexts |
6989 const char* ambiguity_data[] = { | 6973 const char* ambiguity_data[] = { |
6990 "var foo = { x = 10 } = {};", | 6974 "var foo = { x = 10 } = {};", |
6991 "var foo = { q } = { x = 10 } = {};", | 6975 "var foo = { q } = { x = 10 } = {};", |
6992 "var foo; foo = { x = 10 } = {};", | 6976 "var foo; foo = { x = 10 } = {};", |
6993 "var foo; foo = { q } = { x = 10 } = {};", | 6977 "var foo; foo = { q } = { x = 10 } = {};", |
6994 "var x; ({ x = 10 } = {});", | 6978 "var x; ({ x = 10 } = {});", |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7764 "var publ\\u0069c = 1;", | 7748 "var publ\\u0069c = 1;", |
7765 "var { publ\\u0069c } = {};", | 7749 "var { publ\\u0069c } = {};", |
7766 NULL}; | 7750 NULL}; |
7767 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, | 7751 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, |
7768 always_flags, arraysize(always_flags)); | 7752 always_flags, arraysize(always_flags)); |
7769 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7753 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
7770 always_flags, arraysize(always_flags)); | 7754 always_flags, arraysize(always_flags)); |
7771 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7755 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
7772 always_flags, arraysize(always_flags)); | 7756 always_flags, arraysize(always_flags)); |
7773 } | 7757 } |
OLD | NEW |