Build and test a regular expression
Describe what you want to match and get a commented regex with matching and non-matching test cases.
Generate a well-organized test suite covering happy paths, edge cases and failure modes for code you paste in.
Write unit tests for the {{language}} code below using {{framework}}.
Code under test:
{{code}}
Behavior notes or requirements (optional): {{requirements}}
Requirements for the tests:
- First list, in plain bullets, the behaviors you will cover, grouped as: normal cases, boundary values, invalid input, and error or exception paths. Add concurrency, time or I/O cases only if the code involves them.
- Then write the full test file. Use descriptive test names that read as sentences about behavior, one logical assertion per test, and a clear arrange / act / assert structure.
- Prefer table-driven or parameterized tests when several cases share a shape.
- Mock only true external boundaries (network, clock, filesystem, database). Do not mock the code under test.
- Do not change the code under test. If you think you found a bug while writing a test, keep the test, mark it clearly, and explain the bug after the file.
- Keep tests deterministic: no real sleeps, no random data without a fixed seed.
After the code, list anything you could not test and why, and note any assumptions you made about intended behavior.Listing the behaviors before the code makes the model reason about coverage first. The rule against changing the code under test turns suspected bugs into visible findings.
Licensed CC0 (public domain) Version 1 · history
Describe what you want to match and get a commented regex with matching and non-matching test cases.
Practice algorithm problems with progressive hints, complexity analysis and feedback, instead of getting spoiled with the answer.
Port code to another language so it reads like native code, with notes on behavior differences and gotchas.
Systematically narrow down why a test or bug only fails sometimes, with experiments to prove the cause.
Understand code you inherited: a layered explanation from the big picture down to the tricky lines.
Describe your messy data and get a prioritized cleaning plan with rules, code and a record of every change you make.
Comments (0)
Sign in to join the discussion.
No comments yet. Be the first to share how it worked.