hegeltest 0.12.0
hegeltest: ^0.12.0 copied to clipboard
Property-based testing for Dart, powered by Hegel's native engine. Automatically finds edge cases by generating random inputs and shrinking failures to minimal counterexamples.
0.12.0 #
- New: Added engine-guided
recursive<T>(base, extend, {int maxDepth = 32, int maxLeaves = 100})generator backed bylibhegel's native recursion C ABI (hegel_new_recursion,hegel_recursion_branch,hegel_recursion_leaf,hegel_recursion_retry,hegel_recursion_finish,hegel_recursion_free) for generating and shrinking trees, ASTs, and JSON-like structures toward a single leaf. - New: Added
deferred<T>(definition)lazy generator combinator for self-referential and mutually recursive generator definitions, with cycle detection, bounded fresh-instance chain/label traversal, and span-depth protection (MAX_DEPTH = 1000) against stack overflow on unguarded recursion. - Safety & Shrinking: Roll back Dart-side
TestCasedraw logs, notes, staged observations, and coverage targets across discardedrecursive()retry attempts, share compound span labels across subtrees, and guard subtree generators against reuse outside theirextend()branch.
0.11.0 #
- Engine Upgrade: Upgraded bundled native library to upstream
hegeldev/hegellibhegel 0.53.2(macos_arm64,linux_x64,linux_arm64,windows_x64,windows_arm64), reducing test-function calls during mutation shrinking by abandoning candidates after five consecutive exhausted continuations. - Shrinking: Derive compound span labels via
hegel_label_combineacross nested collections (lists,sets,maps), combinators (oneOf,frequency,nullable,tuples2/3/4), andmap/where/flatMap/Generator.compositegenerators for improved shrink structure on composed and heterogeneous generators. - Fix: Snapshot caller-supplied input lists in
sampled,sampledWeighted,oneOf, andfrequencyto prevent external mutation after generator construction, and guard cyclic self-referential generators during compound span-label derivation.
0.10.1 #
- Dependencies: Widen
code_assetsconstraint to>=1.2.0 <3.0.0to supportcode_assets2.x(2.2.0). - Docs: Add dartdoc comments for
Failure,RunResult, and settings enumvaluefields.
0.10.0 #
- Engine Upgrade: Upgraded bundled native library to upstream
hegeldev/hegellibhegel 0.53.1(macos_arm64,linux_x64,linux_arm64,windows_x64,windows_arm64) with automated./tool/fetch_libhegel.shfetcher and SHA256 sidecar verification. - Native Assets: Migrated FFI bindings (
ffigenffi-native) to Dart@Nativecode assets (assetId: package:hegeltest/src/ffi/hegel_bindings.g.dart), registered automatically viahook/build.dart. ReplacedHEGEL_LIBHEGEL_PATHwith build-hook configurationhooks.user_defines.hegeltest.libhegel_path. - New: Added
durations({Duration? min, Duration? max})temporal generator (min/maxdefaults to ±36500 days at microsecond precision). - New: Added
tc.note(String message)for attaching diagnostic notes to test cases, surfaced automatically underNotes:in failing counterexample reports and blob replays. - New: Added
RunErrorKind(RunResult.errorKind) for structured classification of errored runs (none,healthCheck,flaky,nondeterministic,unsatisfiable,usage,internal). - New: Exported conditional
ensureHegelLibraryVerified()andhegelNativeVersion()frompackage:hegeltest/hegeltest.dart. - Stateful Testing: Added
StateRule.weight(default1.0),StateInvariant.alwaysCheck(defaulttrue, with initial and final checks always executed),StateMachine.stepCount(default50), precondition rejection feedback viahegel_state_machine_rule_rejected, and clean 2-argrunStateMachine(TestCase tc, StateMachine machine). - Breaking Changes:
- Removed
loadHegelLibrary(),HegelRunner(LibHegel lib)constructor argument (now zero-argHegelRunner()),RunMode,Backend.auto_, andHEGEL_LIBHEGEL_PATH. - Updated
Verbosityenum values (normal(0),quiet(1),verbose(2),debug(3)) andRunStatus(passed,failed,error) to matchlibhegel 0.53.1. - Updated
runStateMachinesignature from 5 arguments torunStateMachine(TestCase tc, StateMachine machine).
- Removed
0.9.1 #
- Fix: Free native
hegel_string_generator_thandles at end-of-run (hegel_string_generator_free) and cache handles per-run by structural generator parameters onRunLifecycle. - Fix: Enrich string and regex generator build failures with native engine diagnostics (
hegelExceptionWithDetail). - Fix: Throw
hegelExceptionWithDetailon FFI failures instateful_runner.dartinstead of continuing with uninitialized out-pointers, and validate rule/invariant names against NUL bytes (\x00). - Fix: Propagate
machine.tearDown()exceptions inhegelStatefulTestwhen the stateful body succeeded. - Fix: Add package-URI and
.dart_tool/package_config.jsonfallback toloadHegelLibrary()soflutter testresolves the bundled native binary when.dart_tool/lib/is not populated. - Fix: Deduplicate repeated
tc.cover()calls for the same label within a single iteration and rejectNaNintc.cover(),tc.target(),booleans(), andnullable(), as well as non-positivemaxAttemptsinGenerator.where(). - Fix: Encode sub-second
DateTimeGeneratorbounds asmillisecond * 1000 + microsecond, normalizemin/maxbounds to UTC via.toUtc(), fix defaultdateTimes()maxbound, and validate bounds/sizes inDateGenerator,TimeGenerator,DateTimeGenerator, andBytesGenerator. - Fix: Support nullable
Pool<T?>values in stateful testing by checking!_pool.values.containsKey(varId)instead ofvalue == null. - Fix: Skip
package:flutter_test/,package:flutter/, andpackage:hegeltest_flutter/frames and strip surrounding parentheses inextractOrigin. - Fix: Replay winning shrunk failure reproduction blobs at the end of
HegelRunner.runWithResultwhen more than one test case ran, clear_caughtExceptionsper run, and record qualifying replay exceptions so reports can use the winning replay instead of a rejected shrink probe. - API: Export
runStateMachinefrompackage:hegeltest/hegeltest.dart.
0.9.0 #
- New:
tc.classify(condition, observation, {label})— conditional observation tracking combinator for input distribution monitoring. - New:
tc.cover(minPercentage, condition, label)— minimum distribution coverage assertion. Asserts that edge cases are exercised across at leastminPercentage% of valid test cases, throwingInsufficientCoverageExceptionif unmet. - New:
sampledWeighted(List<(int, T)>)— generator for weighted sampling from raw values without requiring generator wrapping. - New:
oneOfWeighted(List<(int, Generator<T>)>)— discoverable alias forfrequency()matching theoneOfcombinator naming convention. - New: Export
InsufficientCoverageExceptionfrom root library.
0.8.0 #
- New: Persistent Counterexample Database — automatically caches failing counterexamples to
.hegel/examples/(scoped by test description). Subsequent runs replay known failing examples first on iteration 1 duringPhase.reusefor instant regression detection. - New: Automatic
.gitignorecreated inside.hegel/to keep developer worktrees clean. - New: Opt-out support via
database: falseparameter orHEGEL_DATABASE=0environment variable. - New: Custom database storage support via
databasePath: String. - New:
example/database_example.dartand comprehensivetest/database_test.dartsuite.
0.7.0 #
- New:
tc.collect()— observation distribution tracking API. Gather and verify input distributions across valid test cases. Automatically discards observations from rejected cases (tc.assume). - New:
RunResult.statistics&RunResult.formatStatistics()— access and format collected observations programmatically. - Reporting: Formatted statistics distribution is printed automatically on test completion when
verbosity: Verbosity.verbose. - Quality: Resolved all linter infos and dangling doc comments across
lib/for 100% pub.dev score (160/160 points). Replaced deprecatedpackage:test_apiimport withpackage:test.
0.6.1 #
- Fix: Add
runWithResult()to web stubHegelRunner— fixesundefined_methodanalyzer error in downstream packages (e.g.hegeltest_flutter)
0.6.0 #
- New:
runHegelTest()— standalone property runner that returnsRunResultwithoutpackage:testdependency. Use for custom runners, CI integration, or programmatic analysis. - New: Examples — stateful testing (
StackMachine,Pool<String>), composite generators (User,Address), and reproduction workflow - New: Test coverage for temporal (
dates,times,dateTimes), network (ipv4Addresses,ipv6Addresses), andurls()generators - Docs:
CONTRIBUTING.md,CODE_OF_CONDUCT.md, issue/PR templates - Docs: README — documented
assume(),target(), named draws,HEGEL_SEED,database/databaseKey, advanced settings, standalone runner
0.5.0 #
- Breaking: Minimum Dart SDK bumped to
>=3.10.0(was>=3.4.0) - New: Native Assets integration —
hook/build.dartregisters prebuilt binaries automatically. No more manual path resolution. - Simplified
library_loader.dart(297 → 170 lines) - Moved SHA256 integrity verification to build time (
hook/build.dart) - CI now tests native assets workflow (not env override)
- Added
hooksandcode_assetsdependencies - Graceful handling of unsupported targets (returns empty asset list, no build crash)
HEGEL_LIBHEGEL_PATHenv override still works (runtime only)
Migration: If on Dart >=3.10.0, just bump to
hegeltest: ^0.5.0. If on Dart <3.10.0, stay onhegeltest: ^0.4.0(security fixes only).
0.4.0 #
- New: Stateful (model-based) testing —
hegelStatefulTest(),StateMachine,StateRule,StateInvariant - New:
Pool<T>for typed value tracking across rules (reusable/consumed draws) - New: Structured preconditions on rules — evaluated before engine selection, not inside rule bodies
- Engine-driven Swarm Testing automatically explores rule subsets
- Automatic shrinking of step sequences to minimal counterexamples
0.3.0 #
- Security: SHA256 integrity verification for all bundled native binaries
- Supply chain: Bundled
.sha256checksum files alongside each binary - Binaries are verified before loading — corrupted/tampered files throw
StateErrorwith actionable error message
0.2.2 #
- Fix: Library loader finds native binary in
flutter testviapackage_config.jsonfallback
0.2.1 #
- API: Export
HegelRunnerandloadHegelLibraryfor downstream packages (e.g.hegeltest_flutter) - DX: Clean up test imports to use package exports only
0.2.0 #
- Cross-platform: Bundled native binaries for Linux x64, Linux arm64, Windows x64, and Windows arm64
- Safety: ABI version check on library load — prevents segfaults from mismatched binary versions
- Upgrade: Native engine updated to hegel-rust v0.32.2
- CI: Tests now run on macOS, Linux, and Windows
0.1.2 #
- Web compat: Conditional imports — web projects that import hegeltest compile cleanly (throws
UnsupportedErrorat runtime) - DX:
HegelTestFailureextendsTestFailurefrompackage:test_api— cleaner test output without framework stack traces - Fix: Pre-existing type errors in example and reproduce_test
0.1.1 #
- Performance: Cache string generator handles per context (was recompiling regex per draw)
- Performance: BigInt byte extraction via bit shifts (was string parsing per draw)
- Performance: Replace Arena malloc/free with
reuseBufferin all combinators + collections - Performance: Cache
Generator.typeName(wasruntimeType.toString()per draw) - Performance: Rewrite tuple generators as direct subclasses (removes double-span + Arena)
- Fix: Clone finalizer now frees
_bufferCache(was leaking FFI pointers on GC) - Fix: BigInt
outLenbounds check prevents out-of-bounds read - Fix: Blob replay now calls
setUpEach/tearDownEachand wraps body in zone guard - Fix: Late async errors logged to stderr (was silently swallowed)
- Fix:
FilteredGeneratorseparates predicate rejection from exception inhadError - Fix: Collection rejection sets
hadErrorcorrectly beforeHegelAssumptionViolated - Fix:
toString()safety in counterexample formatting (catches throwingtoString) - Fix: Surrogate-safe truncation via
runes.take(200) - DX:
tearDownEacherrors now include full stack trace - DX:
HegelConfigfields have dartdocs - DX:
where()acceptsmaxAttemptsparameter (default 100) - DX: Reproduce blob validated for NUL bytes before FFI boundary
0.1.0 #
- Initial release
- Core
hegelTest()integration withpackage:test - 25+ generators: primitives, text, collections, combinators, temporal, network, bytes
- Generator composition:
map(),flatMap(),where(),Generator.composite() HegelConfigfor reusable test configuration- Per-iteration isolation via
setUpEach/tearDownEach - Counterexample recording with draw log in failure messages
- Reproduction blobs for deterministic failure replay
- Buffer reuse optimization for primitive generators
- Comprehensive dartdocs on all public APIs