mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibJS: Move tests to /Tests/LibJS
This commit is contained in:
committed by
Tim Flynn
parent
c059c6a2f5
commit
e3faa9b5ad
Notes:
github-actions[bot]
2026-02-06 11:17:48 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/e3faa9b5add Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7572 Reviewed-by: https://github.com/trflynn89 ✅
53
Tests/LibJS/Runtime/comments-basic.js
Normal file
53
Tests/LibJS/Runtime/comments-basic.js
Normal file
@@ -0,0 +1,53 @@
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user