ladybird/Userland/Libraries/LibJS/Tests/eval-basic.js
Andreas Kling 45e6b5e601 LibJS: Make eval() return the last value from the executed statement
This is kinda awkward but since the statement we're executing is
actually a JS::Program, we have to get the result via VM::last_value().
2021-03-15 21:43:40 +01:00

10 lines
201 B
JavaScript

test("basic eval() functionality", () => {
expect(eval("1 + 2")).toBe(3);
function foo(a) {
var x = 5;
eval("x += a");
return x;
}
expect(foo(7)).toBe(12);
});