mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-26 04:22:07 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 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();
 | |
| });
 | 
