Trust, but Verify
About this app
Five short functions as an assistant delivers them, each plausible and each with a typical error: edge case, invented library function, eval on form input, swapped date format, wrong domain logic. Tap the suspicious line, then check with five methods: read the code, check the docs, example, edge case, recompute. The log shows real Python 3.13 output; the matrix collects which method reveals which error: reading versus trying out.
Trust, but verify
Code from AI assistants often looks plausible and runs, yet can contain bugs. Typical ones are forgotten edge cases, invented library functions, unsafe patterns such as eval on user input, wrong assumptions about formats and wrong domain logic. No single checking method finds all of them. Reading reveals unsafe patterns and wrong format codes, running with an example and an edge case finds crashes, and recalculating finds results that run but are wrong. Anyone adopting AI code should therefore combine reading and testing.
What the app shows
Five short tasks, each with the Python function an assistant returns: average price, weighted average, a price formula from a web form, parsing a delivery date and net amount from gross. Each contains a bug, such as division by zero for an empty list, the invented function statistics.weighted_mean, eval on form input, the format %m.%d.%Y for German dates, or gross * 0.81 instead of gross ÷ 1.19. A log shows real Python 3.13 output.
Try it yourself
First tap the line you find suspicious. Then check it with five methods: read the code, check the docs, run an example, test an edge case and recalculate against the requirement. A matrix collects which method reveals which bug. In the end it becomes clear that reading and testing find different bugs and that no method uncovers all five.
Frequently asked questions
- How do you check code written by an AI?
- Combine several methods: read the code line by line, look up unfamiliar functions in the documentation, run it with an example and with edge cases, and recalculate the result against the requirement. Each method finds different kinds of bugs.
- Why is eval on user input dangerous?
- eval executes a string as Python code. If the string comes from a form, someone can inject arbitrary code and have it run on the server. For arithmetic expressions, use a dedicated, restricted parser instead.
- What are hallucinated functions in AI code?
- These are functions or parameters that sound plausible but do not exist in the library. The code then fails on the first call. Checking the official documentation shows whether the function exists and what it does.
- Which cases does the app contain?
- Five functions with one bug each: empty-list edge case, invented library function, eval on form input, swapped date format and wrong VAT calculation. For each case the app shows which checking methods reveal it.
Subject: Software engineering
More from Software engineering
- Class Diagram and Code in Sync
- Tests as a Safety Net
- Token Game in Activity Diagrams
- Waterfall or Agile?
- WIP Limit and Lead Time
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps