summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2021-11-26 23:37:14 +0100
committerLinus Groh <mail@linusgroh.de>2021-11-30 17:05:32 +0000
commit156dfe3d629f36a03bdcde3a9a253934e45dd4de (patch)
tree22425793ccb57f136d299b776a7740ef15f13588 /Userland/Libraries/LibJS/Tests
parent51e23cd04303e6cd18987d90dec4cc032341b371 (diff)
downloadserenity-156dfe3d629f36a03bdcde3a9a253934e45dd4de.zip
LibJS: Disallow member expression in binding pattern as parameters
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js b/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js
index 7a709a31bb..198561c4a8 100644
--- a/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js
+++ b/Userland/Libraries/LibJS/Tests/syntax/destructuring-assignment.js
@@ -46,6 +46,20 @@ describe("parsing", () => {
expect(`const [ a, [ ...{length} ] ] = [];`).toEval();
expect(`let [ a, [ ...{length} ] ] = [];`).toEval();
});
+
+ test("function parameters cannot use member expresssions", () => {
+ expect("function f([a.b]) {}").not.toEval();
+ expect("function f([b[0]]) {}").not.toEval();
+
+ expect("function f({c:a.b}) {}").not.toEval();
+ expect("function f({a:b[0]}) {}").not.toEval();
+
+ expect("([a.b]) => 1").not.toEval();
+ expect("([b[0]]) => 2").not.toEval();
+
+ expect("({c:a.b}) => 3").not.toEval();
+ expect("({a:b[0]}) => 4").not.toEval();
+ });
});
describe("evaluating", () => {