2023-08-09 15:14:05 -04:00
|
|
|
test.xfail("assignment to function call", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
|
function foo() {}
|
|
|
|
|
foo() = "foo";
|
|
|
|
|
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
|
2020-07-03 14:39:25 -07:00
|
|
|
});
|
2020-04-10 00:39:33 +01:00
|
|
|
|
2024-01-31 22:27:11 +00:00
|
|
|
test.xfail("Postfix operator after function call", () => {
|
|
|
|
|
expect(() => {
|
|
|
|
|
function foo() {}
|
|
|
|
|
foo()++;
|
|
|
|
|
}).toThrow(ReferenceError);
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-05 00:00:10 +01:00
|
|
|
test("assignment to function call in strict mode", () => {
|
2022-11-30 01:47:25 +01:00
|
|
|
expect("'use strict'; foo() = 'foo'").toEval();
|
2020-10-05 00:00:10 +01:00
|
|
|
});
|
|
|
|
|
|
2023-08-09 15:14:05 -04:00
|
|
|
test.xfail("assignment to inline function call", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
|
(function () {})() = "foo";
|
|
|
|
|
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
|
2020-07-03 14:39:25 -07:00
|
|
|
});
|
2020-10-04 23:58:57 +01:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
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();
|
|
|
|
|
expect("1 = 1").not.toEval();
|
2022-11-30 01:47:25 +01:00
|
|
|
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();
|
2020-10-04 23:58:57 +01:00
|
|
|
});
|