"""Illustrate test adequacy and oracle correctness. Python 3.10+, no packages.

Policy: for nonnegative integer order totals, shipping costs 500 cents below
5000 cents and zero cents at or above 5000. The cases and deliberately wrong
implementations below are hand-authored illustrations, not LLM outputs or a
benchmark. No production files are modified. Only the chosen finite cases
and changes are checked; passing is not a general proof of correctness.
"""
from collections.abc import Callable

Fee = Callable[[int], int]
Cases = tuple[tuple[int, int], ...]


def shipping_fee(total_cents: int) -> int:
    if total_cents >= 5000:
        return 0
    return 500


def boundary_bug(total_cents: int) -> int:
    if total_cents > 5000:
        return 0
    return 500


def always_free(total_cents: int) -> int:
    return 0


def never_free(total_cents: int) -> int:
    return 500


def equivalent_refactor(total_cents: int) -> int:
    return 500 if total_cents < 5000 else 0


def passes(implementation: Fee, cases: Cases) -> bool:
    return all(implementation(total) == expected for total, expected in cases)


def main() -> None:
    ordinary_cases = ((4999, 500), (5001, 0))
    boundary_cases = ordinary_cases + ((5000, 0),)
    wrong_oracle_cases = ordinary_cases + ((5000, 500),)
    mutants = (boundary_bug, always_free, never_free)

    # Both original branches execute in the ordinary cases, but the boundary
    # fault is observationally indistinguishable on those selected inputs.
    assert passes(shipping_fee, ordinary_cases)
    assert passes(boundary_bug, ordinary_cases)
    assert passes(shipping_fee, boundary_cases)
    assert not passes(boundary_bug, boundary_cases)
    assert passes(equivalent_refactor, boundary_cases)
    assert not passes(shipping_fee, wrong_oracle_cases)
    assert passes(boundary_bug, wrong_oracle_cases)

    weak_kills = sum(not passes(m, ordinary_cases) for m in mutants)
    strong_kills = sum(not passes(m, boundary_cases) for m in mutants)
    assert (weak_kills, strong_kills) == (2, 3)
    print(f"Ordinary examples: {weak_kills}/3 chosen faults detected")
    print(f"With the boundary case: {strong_kills}/3 chosen faults detected")
    print("Equivalent refactor: accepted by the improved tests")
    print("Wrong expected answer: rejects correct code, accepts the boundary bug")


if __name__ == "__main__":
    main()
