VCF

Unit 8 · Vibe coding with guardrails

Test the edge case: where AI code breaks

Test the boundary the spec names. If shipping is free “at $50 or more”, try exactly $50; if sign-up is for “18 and over”, try 18. Work out each expected answer from the spec, never by copying what the code returns.

The mix-up

What people often think

“A couple of normal orders are enough to test it.”

What the tutor says

Bugs hide at the edges. "$50 or more" has an edge at exactly $50, so test that number.

How it works

One run proves one input. A calculator can be right at $20 and $80 and wrong at exactly $50, and no error message will tell you: wrong answers rarely crash.

Huge numbers rarely break a simple rule; the boundary is where off-by-one mistakes live. And an AI that tested its own code tested it against what it thought you meant, so its tests share its misunderstanding.

An example

What worksJavaScript
// spec: free shipping at $50 or more, otherwise $8
check(shipping(49.99), 8);
check(shipping(50), 0);    // the boundary
check(shipping(80), 0);
Expected values come from the spec.

Close cousins of this mix-up

The tutor watches for these in the same lesson.

  • “If it worked once, it works for everything.”

    One run tests one input. A calculator can be right for $20 and $80 and wrong at exactly $50. You only know by trying $50.

  • “Extreme values make the toughest tests.”

    Huge numbers rarely break a simple rule. The boundary in the spec, here 18, is where off-by-one mistakes live.

  • “The expected value is whatever the function returns.”

    If you copy the answer from the code, your test agrees with the bug. Work out each expected value from the spec, then see if the code matches.

  • “The AI tested the code it wrote, so it is correct.”

    The AI tests against what it thinks you meant. If it misread the spec, its tests share the same mistake. Your checks come from your spec.

Practise it with a tutor watching

Test it yourself

Write checks for AI code from the spec, including the edge case most likely to hide a bug.

20 minutes See it Build it Break it Say it
Start the lesson

Free, no account needed.