ladybird/Userland/Libraries/LibJS/Tests/comments-basic.js
Linus Groh 299c3069c1 LibJS/Tests: Use eval() for toEvalTo(), not Function()
Since we have had eval() for a while now, we can finally use it here -
this allows us to get rid of the confusing return statements in tested
source code.
2021-06-18 20:35:23 +01:00

35 lines
548 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("unterminated multi-line comment", () => {
expect("/*").not.toEval();
expect("/**").not.toEval();
expect("/*/").not.toEval();
expect("/* foo").not.toEval();
expect("foo /*").not.toEval();
});