mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:22:44 +00:00 
			
		
		
		
	 d52ea37717
			
		
	
	
		d52ea37717
		
	
	
	
	
		
			
			The interpreter now considers a statement or block's label when considering whether or not to break. All statements can be labelled.
		
			
				
	
	
		
			72 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| load("test-common.js");
 | |
| 
 | |
| /**
 | |
|  * This file tests automatic semicolon insertion rules.
 | |
|  * If this file produces syntax errors, something is wrong.
 | |
|  */
 | |
| 
 | |
| function bar() {
 | |
|     // https://github.com/SerenityOS/serenity/issues/1829
 | |
|     if (1)
 | |
|         return 1;
 | |
|     else
 | |
|         return 0;
 | |
| 
 | |
|     if (1)
 | |
|         return 1
 | |
|     else
 | |
|         return 0
 | |
| 
 | |
|     if (1)
 | |
|         return 1
 | |
|     else
 | |
|         return 0;
 | |
|     
 | |
| }
 | |
| 
 | |
| function foo() {
 | |
|     label:
 | |
|     for (var i = 0; i < 4; i++) {
 | |
|         break // semicolon inserted here
 | |
|         continue // semicolon inserted here
 | |
| 
 | |
|         break label // semicolon inserted here
 | |
|         continue label // semicolon inserted here
 | |
|     }
 | |
| 
 | |
|     var j // semicolon inserted here
 | |
| 
 | |
|     do {
 | |
|     } while (1 === 2) // semicolon inserted here
 | |
| 
 | |
|     return // semicolon inserted here
 | |
|     1;
 | |
| var curly/* semicolon inserted here */}
 | |
| 
 | |
| function baz() {
 | |
|     let counter = 0;
 | |
|     let outer;
 | |
| 
 | |
|     outer:
 | |
|     for (let i = 0; i < 5; ++i) {
 | |
|         for (let j = 0; j < 5; ++j) {
 | |
|             continue // semicolon inserted here
 | |
|             outer // semicolon inserted here
 | |
|         }
 | |
|         counter++;
 | |
|     }
 | |
| 
 | |
|     return counter;
 | |
| }
 | |
| 
 | |
| try {
 | |
|     assert(foo() === undefined);
 | |
|     assert(baz() === 5);
 | |
| 
 | |
|     console.log("PASS");
 | |
| } catch (e) {
 | |
|     console.log("FAIL: " + e);
 | |
| }
 | |
| 
 | |
| // This vardecl must appear exactly at the end of the file (no newline or whitespace after it)
 | |
| var eof
 |