Curriculum

Curriculum

Read the Diff Before You Accept It

Scenario

Zero seats must be declined. Compare two edits to the old condition.

Selected choicePick a choice below
Result—
Diff A
- return true
+ return freeSeats >= 0
Diff B
- return true
+ return freeSeats > 0

Try it yourself

Predict which edit passes the zero-seat test.

Reveal the explanation
  1. + return freeSeats >= 0

    FAIL · For 0 the actual result is true, but the expected result is false.

  2. + 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.

Read free seats
Is the count greater than zero?
Yes
Accept
No
Decline
Free seatsExpectedBefore the fix >= 0After the fix > 0
0falsetrue Failfalse Pass
1truetrue Passtrue Pass
2truetrue Passtrue Pass
Before the fix · After the fix
node examples/booking/booking.test.mjs before
node --test examples/booking/booking.test.mjs
Runnable reference files

Your 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.