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