CtrlK
BlogDocsLog inGet started
Tessl Logo

evilissimo/property-based-testing

Generates **property-based tests** that use randomized input generation to validate invariants and contracts (rather than hand-picked examples). Triggers when the conversation involves: PBT frameworks (Hypothesis library for Python, fast-check for TypeScript, proptest for Rust, rapid for Go, RapidCheck for C++); concepts like invariants, contracts, round-trip symmetry, encode/decode, serialize/deserialize, generative testing, or shrinking; or requests to find edge cases that example-based tests miss — e.g., "find edge cases automatically", "test all possible inputs", "verify this property holds". Does NOT trigger for: writing regular example-based unit tests, debugging, CI/CD setup, UI/component testing, or integration/E2E testing. Identifies up to 7 property patterns (round-trip, idempotence, invariance, metamorphic, inverse, ordering, no-crash), designs input generators, writes property tests, and extracts regression tests from failures.

91

1.11x
Quality

90%

Does it follow best practices?

Impact

94%

1.11x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Pricing Pipeline Test Coverage

Problem/Feature Description

The commerce team has a small Python module that normalizes cart line items before checkout. The existing examples cover a few normal carts, but recent production incidents involved zero quantities, duplicate product IDs, and unusual note text. The team wants tests that explore the behavior more broadly and that would make future counterexamples easy to preserve.

Create a test file for the module below. You do not need to fix the module; focus on a testing approach that can uncover contract violations across many inputs and documents what should be done with any discovered counterexample.

Output Specification

Produce test_cart_properties.py containing runnable pytest-style tests and any helper strategies needed. Also produce TEST_NOTES.md briefly explaining the properties you chose and how failures should be handled.

Input Files

=============== FILE: cart.py ===============

from decimal import Decimal, ROUND_HALF_UP

def normalize_cart(items):
    """Return checkout-ready items.

    Input items are dicts with product_id, quantity, unit_price, and optional note.
    Non-positive quantities are ignored. Duplicate product IDs are combined.
    Totals are rounded to cents as Decimal values.
    """
    merged = {}
    for item in items:
        qty = int(item.get("quantity", 0))
        if qty <= 0:
            continue
        product_id = str(item.get("product_id", ""))
        unit_price = Decimal(str(item.get("unit_price", "0")))
        note = item.get("note")
        if product_id not in merged:
            merged[product_id] = {"product_id": product_id, "quantity": 0, "unit_price": unit_price, "note": note}
        merged[product_id]["quantity"] += qty
    result = []
    for row in merged.values():
        row["total"] = (row["unit_price"] * row["quantity"]).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
        result.append(row)
    return result

evals

scenario-1

criteria.json

task.md

SKILL.md

tessl.json

tile.json