Websites, apps & code / Coding & debugging

Write checks for my code

You keep changing code and worry about breaking it, so you want automatic checks.

Fill in your details

Leave blank to use the example. Names are remembered for other prompts too (stored only on your device).

Variation:Language

Prompt

Please write automatic checks (tests) for the code below.

Code:
(paste a function that works out discounts)
How it should behave: 10% off at RM100, 20% off at RM200, not stacked
Language: Use the simplest setup and teach me how to run it.

Please:
1. Restate the rules in plain words and wait for my confirmation.
2. List the cases to test (normal, edge, bad input) with the expected result for each, using fake numbers.
3. Only then give the test code. Where I was unclear, ask me instead of deciding.
4. Teach me to run it and read the results when something fails.
5. If the tests reveal a bug in the code, say so; do not quietly change the rules to make tests pass.
Do not ask me to paste passwords, API keys, IC numbers or customer data; if my code contains any, remind me to replace them with [FAKE] values first.

Paste it into ChatGPT, Gemini, Claude or Meta AI.

Test result

Run on 2026-12-01 with Claude Sonnet 5.5 (variation: JavaScript), using the example details above. AI never answers word for word the same twice, but the shape stays close.

What we noticed

The function was a placeholder, so the AI only restated the rules and listed test cases, without test code. It raised 5 unclear points such as whether exactly 100 counts and how to round, rather than deciding them itself.

See what the AI actually wrote

Happy to, but the function slot in your message still reads "(paste a function that works out discounts)", so I won't write the test code yet. Here are the first two steps I can do now.

1. The rules restated (please confirm):

  • An order of RM100 or more gets 10% off, so the customer pays 90%.
  • An order of RM200 or more gets 20% off, so the customer pays 80%.
  • "Not stacked": a RM200+ order gets only the 20%, not another 10% on top.
  • Under RM100: no discount.

What I need you to answer (I will not decide these myself):

  1. Does "at RM100" mean ">= 100" or "> 100"? Does exactly 100 count?
  2. Is the discount worked on the original price, or on an amount already reduced by something else?
  3. How are decimals handled? For RM99.99, or a discounted 89.991, round to the cent?
  4. Negatives, 0, blanks and text (such as "abc"): errors, or treated as 0?
  5. Does it return the amount after discount, or the discount itself?

2. Cases to test (fake numbers; expected results assume ">=" and returning the discounted amount):

TypeInputExpected
Normal5050.00
Normal150135.00
Normal300240.00
Edge99.9999.99
Edge10090.00
Edge199.99179.99
Edge200160.00
Bad input-10error or message
Bad input"abc"error or message
Bad inputblankerror or message

The expected values only count once you have answered the questions above.

3. The test code: I have not seen your function name or language, so I will hold off. Once you paste it I will use the simplest setup: Python's built-in unittest, or JavaScript's built-in node:test; nothing to install.

4. How to run (preview): Python: python -m unittest in the terminal; JavaScript: node --test. A failure prints "expected X, got Y", which is where to look.

5. If the tests reveal a bug in your function, I will say so plainly and will not quietly change the rules to make the tests pass.

Please paste the function (no real customer data) and answer the 5 questions above.

AI tools that suit this

  • Claude Suggested tool Free plan

    Strong at long documents, editing and code

  • ChatGPT Suggested tool Free plan

    The most widely used AI chat, for writing, questions and images

  • Cursor Suggested tool Free plan

    AI code editor

Recommendations only, not sponsored. Check each site for what the free plan includes.

This site is made by FullMark Tech

Want your own website, or your shop spreadsheets automated? FullMark Tech builds business websites and custom Excel tools.

Ask on WhatsApp See FullMark Tech services