blob: ec5024f8ec86fe8ecadf71efd02526db5d5458f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
test("assignment to function call", () => {
expect(() => {
function foo() {}
foo() = "foo";
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
});
test("assignment to function call in strict mode", () => {
expect("'use strict'; foo() = 'foo'").not.toEval();
});
test("assignment to inline function call", () => {
expect(() => {
(function () {})() = "foo";
}).toThrowWithMessage(ReferenceError, "Invalid left-hand side in assignment");
});
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();
});
|