mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:57:46 +00:00
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.
This commit is contained in:
parent
2e9f665bda
commit
299c3069c1
5 changed files with 8 additions and 10 deletions
|
@ -37,7 +37,7 @@ test("break/continue, variable declaration, do-while, and return asi", () => {
|
|||
1;
|
||||
var curly/* semicolon inserted here */}
|
||||
|
||||
return foo();`;
|
||||
foo();`;
|
||||
|
||||
expect(source).toEvalTo(undefined);
|
||||
});
|
||||
|
@ -55,7 +55,7 @@ for (let i = 0; i < 5; ++i) {
|
|||
counter++;
|
||||
}
|
||||
|
||||
return counter;`;
|
||||
counter;`;
|
||||
|
||||
expect(source).toEvalTo(5);
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ var i = 0;
|
|||
i++;
|
||||
*/
|
||||
/**/ i++;
|
||||
return i;`;
|
||||
i;`;
|
||||
|
||||
expect(source).toEvalTo(1);
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ i++;
|
|||
--> i++;
|
||||
/**/ --> i++;
|
||||
j --> i++;
|
||||
return i;`;
|
||||
i;`;
|
||||
expect(source).toEvalTo(2);
|
||||
});
|
||||
|
||||
|
|
|
@ -16,5 +16,5 @@ test("object values", () => {
|
|||
});
|
||||
|
||||
test("issue #4409, '?.' followed by decimal digit", () => {
|
||||
expect("return false?.1:.2").toEvalTo(0.2);
|
||||
expect("false?.1:.2").toEvalTo(0.2);
|
||||
});
|
||||
|
|
|
@ -333,13 +333,11 @@ test("toEval", () => {
|
|||
expect("function foo() { return 1; }; foo();").toEval();
|
||||
});
|
||||
|
||||
// FIXME: Will have to change when this matcher changes to use the
|
||||
// "eval" function
|
||||
test("toEvalTo", () => {
|
||||
expect("let a = 1").toEvalTo();
|
||||
expect("let a = 1").toEvalTo(undefined);
|
||||
expect("return 10").toEvalTo(10);
|
||||
expect("return 10").not.toEvalTo(5);
|
||||
expect("10").toEvalTo(10);
|
||||
expect("10").not.toEvalTo(5);
|
||||
|
||||
expect(() => {
|
||||
expect("*^&%%").not.toEvalTo();
|
||||
|
|
|
@ -354,7 +354,7 @@ class ExpectationError extends Error {
|
|||
let result;
|
||||
|
||||
try {
|
||||
result = new Function(this.target)();
|
||||
result = eval(this.target);
|
||||
} catch (e) {
|
||||
throw new ExpectationError();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue