dartproptest 0.2.0
dartproptest: ^0.2.0 copied to clipboard
A property-based testing framework for Dart, inspired by QuickCheck and Hypothesis. Ported from jsproptest.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased] #
0.2.0 - 2025-11-09 #
Added #
- Matrix testing: Added
Property.matrix()method for exhaustive testing via Cartesian product of input lists. Useful for testing all combinations of small input domains (e.g., enum values, edge cases). Similar to cppproptest2's matrix functionality. - Permutation generator: Added
Gen.permutation(List<T>)generator that creates permutations of the provided list. Shrinks towards the identity permutation (original order) by placing out-of-place elements into their correct positions recursively.
0.2.0-rc.1 - 2025-10-30 #
Changed #
- Overhauled shrinking behavior for
accumulateto prioritize logarithmic length shrinks first, followed by element shrinks; preserves constraints and avoids exponential blow-ups. - Updated
aggregateto mirroraccumulatestrategy: length-first shrinking and safe element shrinking (initial element only) to respect state dependencies. - Reworked
chainandflatMapto preserve shrinking from both the original and derived generators; fixed type inference inflatMapfor robust generic handling. - Replaced integer shrinker with a binary-search-based strategy to remove duplicates and ensure complete shrink trees.
Added #
- Deterministic tree structure tests using serialization for
map,filter,chain,flatMap,oneOf,accumulate, andaggregate(including larger known shrink-trees such as 40213/7531246/964285173). - Constraint-preservation tests across combinators to ensure shrinks respect generation constraints.
Fixed #
- Resolved constraint violation and performance issues in
accumulate(removed recursiveelementWiseexplosion). - Ensured
oneOfpreserves the selected generator's tree using non-overlapping domains and deterministic seeds. - Addressed occasional flakiness in tests by seeding
Randomand tightening assertions.
Added #
- Initial release of dartproptest
- Property-based testing framework inspired by QuickCheck and Hypothesis
- Comprehensive generator library for common data types
- Powerful combinators for complex data structures
- Automatic shrinking for easier debugging
- Stateful testing support
- Flutter compatibility across all platforms
- Multiple API variants for different use cases:
forAll- Main function with reflection supportforAllSimple- Flutter-compatible versionforAll1,forAll2, etc. - Numbered variants for type safetyforAllLegacy- Traditional approach
Features #
- Generators: Built-in generators for integers, strings, arrays, objects, booleans, floating-point numbers, sets, dictionaries, and tuples
- Combinators:
just,lazy,elementOf,oneOf,construct,chainTuple - Shrinking: Automatic shrinking algorithms for all data types
- Stateful Testing: Support for testing stateful systems with action sequences
- Platform Support: Works on Dart VM, Flutter web, mobile, and desktop
- Documentation: Comprehensive documentation with examples and guides
Technical Details #
- Zero external dependencies for core functionality
- BSD 3-Clause License
- Dart SDK requirement: >=3.0.0 <4.0.0
- Comprehensive test suite with example tests
- Flutter compatibility documentation