mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	Before this a closing html comment would not be treated as a comment if directly following a block comment which was not the first token of its first line.
		
			
				
	
	
		
			53 lines
		
	
	
	
		
			1,005 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
	
		
			1,005 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
test("regular comments", () => {
 | 
						|
    const source = `
 | 
						|
var i = 0;
 | 
						|
// i++;
 | 
						|
/* i++; */
 | 
						|
/*
 | 
						|
i++;
 | 
						|
*/
 | 
						|
/**/ i++;
 | 
						|
i;`;
 | 
						|
 | 
						|
    expect(source).toEvalTo(1);
 | 
						|
});
 | 
						|
 | 
						|
test("html comments", () => {
 | 
						|
    const source = `
 | 
						|
var i = 0;
 | 
						|
var j = 0;
 | 
						|
<!-- i++; --> i++;
 | 
						|
<!-- i++;
 | 
						|
i++;
 | 
						|
--> i++;
 | 
						|
/**/ --> i++;
 | 
						|
j --> i++;
 | 
						|
i;`;
 | 
						|
    expect(source).toEvalTo(2);
 | 
						|
});
 | 
						|
 | 
						|
test("html comments directly after block comment", () => {
 | 
						|
    expect("0 /* */-->i").not.toEval();
 | 
						|
    expect(`0 /* 
 | 
						|
     */-->i`).toEval();
 | 
						|
    expect(`0 /* 
 | 
						|
     */-->i
 | 
						|
     'a'`).toEvalTo("a");
 | 
						|
});
 | 
						|
 | 
						|
test("unterminated multi-line comment", () => {
 | 
						|
    expect("/*").not.toEval();
 | 
						|
    expect("/**").not.toEval();
 | 
						|
    expect("/*/").not.toEval();
 | 
						|
    expect("/* foo").not.toEval();
 | 
						|
    expect("foo /*").not.toEval();
 | 
						|
});
 | 
						|
 | 
						|
test("hashbang comments", () => {
 | 
						|
    expect("#!").toEvalTo(undefined);
 | 
						|
    expect("#!/bin/js").toEvalTo(undefined);
 | 
						|
    expect("#!\n1").toEvalTo(1);
 | 
						|
    expect(" #!").not.toEval();
 | 
						|
    expect("\n#!").not.toEval();
 | 
						|
    expect("#!\n#!").not.toEval();
 | 
						|
});
 |