Skip to lesson

Path: Coding & reasoning evaluation

Test and review generated code

Use requirements and tests to find the first correctness, edge-case, or safety failure.

Starting level
Comfortable with the basics
Time
26 minutes
Public lesson guide
EN + हिंदी

You will learn to

Turn a code requirement into a test that exposes the first real failure.

Why this matters

Generated code can look fluent while missing edge cases, state changes, or safety constraints.

Three things to remember

  • Test the requirement, not the implementation style.
  • Include boundaries, empty inputs, and failure paths.
  • Repair the root cause before rewriting everything.

See one example

Task

Review a maximum function initialized to zero.

Weak approach

It works for positive inputs, so approve it.

Stronger approach

Run an all-negative case; it returns zero instead of the largest input. Initialize from the first item or handle empty input.

Why the stronger approach works

One targeted test links the failure to the requirement and repair.

Make something yourself

Write one failing test, a root-cause note, and a minimal repair plan.

A useful starting pointExplain why the test failed before suggesting a larger rewrite.
Practise this lesson

Read further

The source is optional. The complete teaching and practice are available inside AI2Bharat.

Read the primary or official source: OpenAI evaluation guidance