ladybird/Userland/Libraries/LibJS/Tests/comments-basic.js

36 lines
562 B
JavaScript
Raw Normal View History

test("regular comments", () => {
const source = `
var i = 0;
// i++;
/* i++; */
/*
i++;
*/
/**/ i++;
return i;`;
2020-04-13 19:50:58 +02:00
expect(source).toEvalTo(1);
});
2020-04-13 19:50:58 +02:00
test("html comments", () => {
const source = `
var i = 0;
var j = 0;
<!-- i++; --> i++;
<!-- i++;
i++;
--> i++;
/**/ --> i++;
j --> i++;
return 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();
});