Code Room
Vibe codingMediumvc-g126
Subject Ai test reviewLevel Mid–Senior~16 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You asked an AI agent to add tests for a Python `discount(price, pct)` that you suspect is buggy. The function rounds with `int(price * (1 - pct))` (truncating, not rounding). The agent ran the code, observed outputs, and wrote tests that pass. Here's one:

python
def test_discount_ten_percent():    # 100 with 10% off should be 90    assert discount(100, 0.10) == 90 def test_discount_fractional():    assert discount(99, 0.10) == discount(99, 0.10)    assert discount(99, 0.10) == 89  # observed value

The second test passes and coverage is now 100%. Why should you not trust these tests, and what would a meaningful test for this function look like?

What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.