Repository navigation
Add property testing suite - #368
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Adds test/laws/ with a LawsSetup testsnippet (Supposition.jl generators, exact lattice predicates, region equivalence), smoke laws for union2d (B1 commutativity, B3 idempotence, B7 membership oracle, B8 validity), and a ledger of three shrunk Clipper1 integer-lattice counterexamples asserted with @test_broken. Supposition is a test-only dependency.
- Made region comparison conservative
- ≐ now passes only canonical boundary equality after collinear stripping.
- Removed the unsound sampled-equality, area, boundary-distance, and containment logic.
- Sampling remains only in B7, where inconclusive examples are rejected rather than passed.
- Removed clipping from generators
- Deleted the clipping-based notched-rectangle generator.
- Replaced it with directly constructed rectangle and star generators.
- Guaranteed degeneracy cases
- Rectangle pairs now deterministically cover translated/overlapping, shared-edge, vertex-touching, collinear-vertex, and unit-sliver cases.
- Added independent assertions for each relationship.
- Replaced circular tests
- Added fixed fixtures for orientation, segment intersection, simplicity, point membership, area, and the thin-triangle disappearance.
- Marked integer B3 as known-broken and updated L3 to assert its normal-form failure with @test_broken.
Extends test/laws/ from four smoke laws to the phase-1 catalog: B1-B11 (boolean algebra, fill rules, tiled clipping, keyhole cuts), O1-O8 (offset and halo), T1 (rigid-transform equivariance), T4 (coordinate-unit invariance), and D1 (prescale round trip). Setup changes: - Generator families: thick and thin integer stars, rectilinear staircases, float stars at nm-100 um scales, fm-perturbed float pairs, triples, polygon sets, and hand-built ClippedPolygon trees with holes. - ClippedPolygon results are compared through their tree contours so the keyhole cut is tested separately (B11). - Exact comparison (≐) remains the verdict wherever calibration shows the law holds exactly (rectilinear inputs; commutativity, identities, single fill rules). `region_within(X, Y, tol)` states rounding laws: exact area budget of tol times the summed perimeters plus membership agreement at probes farther than tol from both boundaries. - Float Quantity coordinates now map to the fm lattice correctly. Ledger adds L4 (hole vertex rounded outside its parent), L5 (`interiorcuts` silently drops such a hole; kernel-independent DL bug), L6 (zero-length keyhole cut), L7 (small offsets leave a sharp corner's vertex on the output), and L8 (fm-scale self-crossing difference output). 151 pass / 24 broken in ~2 min at PR budget.
…ger L9 Offset laws that compose operations (O3, O5, O6) are stated only where |δ|·sin(turn) ≥ 1 at every vertex (outside the L7 regime) and where the first offset produced no edge shorter than 4 lattice units; L9 records the micro-edge mechanism with a reproducer. Normal form (B3) compares regions, since the kernel may split or merge contours touching at a vertex depending on operand order.
An edge of length L with endpoints rounded by half a unit has its direction wrong by ~1/(2L), so a second offset by δ moves the adjacent intersections by ~|δ|/(2L). O5 and O6 use that bound instead of a fixed 2 and no longer reject inputs with short edges; L9 asserts the bound. T1 on rectilinear inputs compares regions.
… joins only Re-union can drop a sub-unit spike left by a rounded intersection, so the normal-form law is exact only on rectilinear input. Erosion with miter or square joins cuts deeper than a disk at concave vertices of the grown polygon, so grow-then-shrink is not guaranteed to contain A with those joins; O6 is stated for round joins.
Rational region certificates replacing sampled acceptance, including cancellation of internal seams Correct float-offset scaling and enforced valid-example budgets Whole-edge hole containment, winding checks, and narrowly scoped L6 handling Full-chord O8 checks, with regression tests for the review counterexamples
…nt-edge reproducer
gpeairs
force-pushed
the
gp/geomlaws-phase0
branch
from
November 9, 2026 13:48
8af073d to
554b990
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a property test suite for DeviceLayout. See
test/laws/README.md. Currently it covers the boolean operations (union2d,intersect2d,difference2d,xor2d,clip,clip_tiled, but not_curvedor_layerwisevariants),offset,interiorcuts, pathhalos, transformations, units, and conversion to and from the Clipper integer grid.It's meant in the near term to validate migration to Clipper2 with higher confidence than our current test suite gives, but it has already caught some issues on our side, as well as some edge cases in Clipper1 and/or Clipper2 that we can patch or warn/error for (see e.g. #349, #350; test findings also drove building Clipper2 with HI_PRECISION for the Julia wrapper).
Instead of checking fixed inputs against expected outputs, each test states a property ("law") that should hold for every input, such as "union is commutative" or "a point is in
A ∪ Bexactly when it is inAor inB", and checks it on inputs generated by Supposition.jl. Outputs are compared as regions of the plane, using exact rational arithmetic that never calls the clipping library under test.I am still thinking about review for a 5k line PR like this, mainly AI-authored with human feedback. It only adds tests, which seem generally good but do take time to run (2 min on normal CI pipelines, with a longer weekly run on main). They also add some maintenance burden if they turn out to be too strict -- we may not want to block on issues that only come up with extremely sharp corners, with points meant to be collinear with diagonal lines, or at Clipper grid scale (femtometers).