Skip to content

test(layout): add jqwik property-based layout invariants#351

Merged
DemchaAV merged 1 commit into
2.0-devfrom
test/jqwik-layout-invariants
Jul 10, 2026
Merged

test(layout): add jqwik property-based layout invariants#351
DemchaAV merged 1 commit into
2.0-devfrom
test/jqwik-layout-invariants

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

The layout suite is example-based — a handful of hand-picked cases per function. Pure engine functions with algebraic contracts (tokenization, z-ordering, weight validation) are exactly where property-based testing earns its keep: it checks the law across the whole input space and shrinks any counter-example to its minimal form. Post-2.0 hardening (B15) asked for jqwik property tests.

What

  • Add the jqwik test dependency (test scope only — never on the published classpath, like ArchUnit). Verified compatible with the project's JUnit Platform 6.1.1.
  • New LayoutInvariantsPropertiesTest — three laws over 1000 generated inputs each:
    • TokenBreaking.softBreakSegments: split then re-join reconstructs the token; no segment is empty.
    • LayerStackGeometry.zOrder: the result is a stable permutation of the source indices, ascending by zIndex (equal zIndex keeps source order).
    • RowSlots.validateWeightsMatchChildren: throws exactly when the weight count differs from the child count.
  • .jqwik-database (jqwik's per-run replay file) added to .gitignore.
  • Test-only; no production code, no public API.

Tests

  • Full core ./mvnw verify -pl . green — 405 tests (401 + 4 properties), javadoc gate and guards pass. Each property reports 1000 tries / 1000 checks.
  • Class named *Test so surefire's default includes discover it (the *Properties name only ran under an explicit -Dtest filter).

Add the jqwik test dependency (test scope only) and property tests for three
pure layout functions: TokenBreaking.softBreakSegments (split then re-join
reconstructs the token, no empty segment), LayerStackGeometry.zOrder (a stable
permutation of the source indices, ascending by zIndex), and
RowSlots.validateWeightsMatchChildren (throws exactly when the weight count
differs from the child count). Each law is checked over 1000 generated inputs,
complementing the example-based unit tests.
@DemchaAV DemchaAV merged commit 177ef35 into 2.0-dev Jul 10, 2026
12 checks passed
@DemchaAV DemchaAV deleted the test/jqwik-layout-invariants branch July 10, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant