Read the Diff Before You Accept It
Scenario
Zero seats must be declined. Compare two edits to the old condition.
- return true
+ return freeSeats >= 0- return true
+ return freeSeats > 0Try it yourself
Predict which edit passes the zero-seat test.
| Case | Result |
|---|---|
| + return freeSeats >= 0 | Select a choice above to see what happens. |
| + return freeSeats > 0 | Select a choice above to see what happens. |
Reveal the explanation
- + return freeSeats >= 0
FAIL · For 0 the actual result is true, but the expected result is false.
- + return freeSeats > 0
PASS · For 0 the result is false, and for 1 it is true.
Inspect the rest of the diff too. Check that the agent changed the intended file and preserved the tests.
Booking rule and test evidence
Accept a booking when at least one seat is free.
| Free seats | Expected | Before the fix >= 0 | After the fix > 0 |
|---|---|---|---|
| 0 | false | true Fail | false Pass |
| 1 | true | true Pass | true Pass |
| 2 | true | true Pass | true Pass |
node examples/booking/booking.test.mjs before
node --test examples/booking/booking.test.mjsYour turn
Predict the zero-seat test, run both commands, and identify the exact line that fixes it.
Common mistake Accepting a plausible comparison without checking the boundary.
Check your work
A failing before run, a passing after run, and the reviewed change from >= 0 to > 0.
This browser could not save your progress. Changes last until you leave the page.