
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.
35 lines
548 B
JavaScript
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();
|
|
});
|