test(layout): add jqwik property-based layout invariants#351
Merged
Conversation
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.
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.
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
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.Tests
./mvnw verify -pl .green — 405 tests (401 + 4 properties), javadoc gate and guards pass. Each property reports 1000 tries / 1000 checks.*Testso surefire's default includes discover it (the*Propertiesname only ran under an explicit-Dtestfilter).