ladybird/Userland/Libraries/LibJS/Tests/postfix-increment-eval-order.js
Andreas Kling b92839fad9 LibJS: Fix bug where argument++ happened before call
For this case to work correctly in the current bytecode world:

    func(a, a++)

We have to put the function arguments in temporaries instead of allowing
the postfix increment to modify `a` in place.

This fixes a problem where jQuery.each() would skip over items.
2024-04-27 17:24:29 +02:00

13 lines
246 B
JavaScript

test("postfix increment evaluation order", () => {
function bar(a, b) {
expect(a).toBe(0);
expect(b).toBe(0);
}
function foo() {
let i = 0;
bar(i, i++);
expect(i).toBe(1);
}
foo();
});