diff options
author | davidot <davidot@serenityos.org> | 2022-11-30 01:47:25 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-30 08:05:37 +0100 |
commit | d218a6829673f3edb5176c332b32920aafc33bcd (patch) | |
tree | f58e0b7b3347ed112b9906c35b038bf7a35265c3 /Userland/Libraries/LibJS/Tests | |
parent | 8319d7ac06256bcfacaeca1ef322dc930fdea963 (diff) | |
download | serenity-d218a6829673f3edb5176c332b32920aafc33bcd.zip |
LibJS: Allow CallExpressions as lhs of assignments in most cases
Although not quite like the spec says the web reality is that a lhs
target of CallExpression should not give a SyntaxError but only a
ReferenceError once executed.
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js b/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js index ec5024f8ec..382078ad8b 100644 --- a/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js +++ b/Userland/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js @@ -6,7 +6,7 @@ test("assignment to function call", () => { }); test("assignment to function call in strict mode", () => { - expect("'use strict'; foo() = 'foo'").not.toEval(); + expect("'use strict'; foo() = 'foo'").toEval(); }); test("assignment to inline function call", () => { @@ -29,4 +29,27 @@ test("assignment to invalid LHS is syntax error", () => { expect("1 >>= 1").not.toEval(); expect("1 >>>= 1").not.toEval(); expect("1 = 1").not.toEval(); + expect("1 &&= 1").not.toEval(); + expect("1 ||= 1").not.toEval(); + expect("1 ??= 1").not.toEval(); +}); + +test("assignment to call LHS is only syntax error for new operators", () => { + expect("f() += 1").toEval(); + expect("f() -= 1").toEval(); + expect("f() *= 1").toEval(); + expect("f() /= 1").toEval(); + expect("f() %= 1").toEval(); + expect("f() **= 1").toEval(); + expect("f() &= 1").toEval(); + expect("f() |= 1").toEval(); + expect("f() ^= 1").toEval(); + expect("f() <<= 1").toEval(); + expect("f() >>= 1").toEval(); + expect("f() >>>= 1").toEval(); + expect("f() = 1").toEval(); + + expect("f() &&= 1").not.toEval(); + expect("f() ||= 1").not.toEval(); + expect("f() ??= 1").not.toEval(); }); |