Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Tests that restate the implementation card 4 of 6

Mirrored oracle vs a worked-out value

builds on: What makes a test able to fail
The BAD test builds `expected` from the same expression `discount` uses, so it only proves the code equals itself. Suppose `discount` had been written as `price * rate`, which gives the amount off (20.0) instead of the price to pay. The agent would have copied `price * rate` into the test, and the test would still be green. The BETTER test states a literal worked out by hand from the spec. A wrong formula turns it red.
# Python
# BAD
def test_discount():
    price, rate = 80.0, 0.25
    expected = price * (1 - rate)
    assert discount(price, rate) == expected

# BETTER: spec says 25% off 80.00 is 60.00
def test_quarter_off():
    assert discount(80.0, 0.25) == 60.0
Terms on this card
oracle
The expected result a test compares against. To be useful it must come from the specification, not from the code being tested.
spec
Specification: the stated rules for what the code should do, such as a requirements document or ticket, independent of how the code is written.
mirrored oracle
An expected value computed with the same formula, constant or helper as the code under test, so it is wrong whenever the code is.
red
A test or check that is failing.
green
A test or check that is passing.
Learn this step by step on Bytewise
Lesson goal: Spot tests whose expected value is computed with the same formula as the code, snapshots that freeze current buggy output, and assertions that check only 'not null' or 'no exception thrown'. Explain why these stay green when the logic is wrong. · the whole lesson