APromptAura
0

Generate property-based tests that find edge cases, not happy-path duplicates

auto-checked, 4 days old
AauraNovice

The prompt

0 copies
Write property-based tests (using {{framework, e.g. Hypothesis / fast-check / QuickCheck}}) for the function below. Do not write example-based tests that just restate the happy path; instead: 1. Identify the invariants the function should always satisfy (e.g. idempotence, round-trip, monotonicity, commutativity where applicable) and encode each as a property. 2. Identify the input domain's edge cases (empty, single-element, max/min values, unicode, negative numbers, duplicates) and make sure the generator can produce them, don't hand-pick a few examples. 3. For any invariant you're not confident actually holds, say so explicitly and mark the test with a comment explaining what you'd expect to see if it fails, rather than silently writing a weak assertion. 4. Keep generators realistic to the function's actual input contract, not maximally adversarial if that's outside the documented contract. Function: code Language: language Known contract/docstring: contract

Run it in your model, then come back and report whether it worked, including the model and version.

Where it has been run

People and our automated sweep are counted separately. Only the People column is someone vouching for this prompt.

ModelVersionPeopleBrokeAutoLast
ClaudeHaiku 4.5001/14 days ago

Example output

Properties written for `normalize_whitespace(s: str) -> str`: 1. Idempotence: `normalize(normalize(s)) == normalize(s)` for all strings, using `st.text()`. 2. Length invariant: output length never exceeds input length. 3. No leading/trailing whitespace in output, for any generated string including ones that are all whitespace. 4. Round-trip on already-normalized strings: `normalize(s) == s` when `s` has single internal spaces and no edges. Flagged uncertain: I'm not confident the function preserves non-breaking spaces (U+00A0) as visible whitespace versus collapsing them, since the docstring only mentions ASCII whitespace. Added a property test with a comment: 'if this fails, decide whether NBSP should be treated as whitespace or preserved, then update the docstring accordingly, this is a spec question not a test bug.' Generator uses `st.text(alphabet=st.characters(whitelist_categories=('Zs','Cc')))` mixed with printable text to hit whitespace-heavy edge cases realistically.

0 comments

Sign in to comment or report what this prompt did for you.

Sign in

No comments yet. Run the prompt and report what you got.