diff options
author | Linus Groh <mail@linusgroh.de> | 2020-10-05 12:30:08 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-05 14:34:37 +0200 |
commit | 2d4cd5b49b9b9d800aa24e8dccc042ed9257d1a7 (patch) | |
tree | 2c24edb9bcc86ccd213fbfcf246f555dd5497992 /Libraries/LibJS/Tests/operators/assignment-operators.js | |
parent | 7fd4646acb65bc0611d8a57f1e650a158d01dc53 (diff) | |
download | serenity-2d4cd5b49b9b9d800aa24e8dccc042ed9257d1a7.zip |
LibJS: Evaluate AssignmentExpression LHS before RHS according to the spec
Fixes #3689.
Diffstat (limited to 'Libraries/LibJS/Tests/operators/assignment-operators.js')
-rw-r--r-- | Libraries/LibJS/Tests/operators/assignment-operators.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/operators/assignment-operators.js b/Libraries/LibJS/Tests/operators/assignment-operators.js index cbe9ee26fa..1078e4202a 100644 --- a/Libraries/LibJS/Tests/operators/assignment-operators.js +++ b/Libraries/LibJS/Tests/operators/assignment-operators.js @@ -53,3 +53,38 @@ test("basic functionality", () => { expect((x >>>= 2)).toBe(2); expect(x).toBe(2); }); + +test("evaluation order", () => { + for (const op of [ + "=", + "+=", + "-=", + "*=", + "/=", + "%=", + "**=", + "&=", + "|=", + "^=", + "<<=", + ">>=", + ">>>=", + ]) { + var a = []; + function b() { + b.hasBeenCalled = true; + throw Error(); + } + function c() { + c.hasBeenCalled = true; + throw Error(); + } + b.hasBeenCalled = false; + c.hasBeenCalled = false; + expect(() => { + new Function(`a[b()] ${op} c()`)(); + }).toThrow(Error); + expect(b.hasBeenCalled).toBeTrue(); + expect(c.hasBeenCalled).toBeFalse(); + } +}); |