The law arena
A domain declares laws for its ops: commutative, associative, idempotent and an identity. An evaluator can use a law, for example to reduce a list in any order. Thus a false claim gives wrong results.
The law checker of @mark1russell7/vex-testkit turns each claim into a property test with fast-check. It runs here in your browser, with the same code as CI.
The checker runs 200 random cases for each law. It runs in your browser, with the same code as CI.
The hunt. The old Color.add said that it is commutative. Find the lie.
The hunt
Section titled “The hunt”The old Vex declared that Color.add is commutative. But a.add(b) kept the alpha of a, so a.add(b) and b.add(a) were different when the alpha values were different. No test found it for a year.
Select “Run the property”: fast-check finds a counterexample, and then it makes the counterexample smaller, one step at a time. Select “Next shrink step” to see each step. The last step is the smallest case that breaks the law.
The new Color.add keeps the larger alpha. With that change, the law holds, and the arena above shows it.