Skip to main content

hegeltest 0.12.0 copy "hegeltest: ^0.12.0" to clipboard
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 by libhegel'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 TestCase draw logs, notes, staged observations, and coverage targets across discarded recursive() retry attempts, share compound span labels across subtrees, and guard subtree generators against reuse outside their extend() branch.

0.11.0 #

  • Engine Upgrade: Upgraded bundled native library to upstream hegeldev/hegel libhegel 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_combine across nested collections (lists, sets, maps), combinators (oneOf, frequency, nullable, tuples2/3/4), and map/where/flatMap/Generator.composite generators for improved shrink structure on composed and heterogeneous generators.
  • Fix: Snapshot caller-supplied input lists in sampled, sampledWeighted, oneOf, and frequency to prevent external mutation after generator construction, and guard cyclic self-referential generators during compound span-label derivation.

0.10.1 #

  • Dependencies: Widen code_assets constraint to >=1.2.0 <3.0.0 to support code_assets 2.x (2.2.0).
  • Docs: Add dartdoc comments for Failure, RunResult, and settings enum value fields.

0.10.0 #

  • Engine Upgrade: Upgraded bundled native library to upstream hegeldev/hegel libhegel 0.53.1 (macos_arm64, linux_x64, linux_arm64, windows_x64, windows_arm64) with automated ./tool/fetch_libhegel.sh fetcher and SHA256 sidecar verification.
  • Native Assets: Migrated FFI bindings (ffigen ffi-native) to Dart @Native code assets (assetId: package:hegeltest/src/ffi/hegel_bindings.g.dart), registered automatically via hook/build.dart. Replaced HEGEL_LIBHEGEL_PATH with build-hook configuration hooks.user_defines.hegeltest.libhegel_path.
  • New: Added durations({Duration? min, Duration? max}) temporal generator (min/max defaults to ±36500 days at microsecond precision).
  • New: Added tc.note(String message) for attaching diagnostic notes to test cases, surfaced automatically under Notes: 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() and hegelNativeVersion() from package:hegeltest/hegeltest.dart.
  • Stateful Testing: Added StateRule.weight (default 1.0), StateInvariant.alwaysCheck (default true, with initial and final checks always executed), StateMachine.stepCount (default 50), precondition rejection feedback via hegel_state_machine_rule_rejected, and clean 2-arg runStateMachine(TestCase tc, StateMachine machine).
  • Breaking Changes:
    • Removed loadHegelLibrary(), HegelRunner(LibHegel lib) constructor argument (now zero-arg HegelRunner()), RunMode, Backend.auto_, and HEGEL_LIBHEGEL_PATH.
    • Updated Verbosity enum values (normal(0), quiet(1), verbose(2), debug(3)) and RunStatus (passed, failed, error) to match libhegel 0.53.1.
    • Updated runStateMachine signature from 5 arguments to runStateMachine(TestCase tc, StateMachine machine).

0.9.1 #

  • Fix: Free native hegel_string_generator_t handles at end-of-run (hegel_string_generator_free) and cache handles per-run by structural generator parameters on RunLifecycle.
  • Fix: Enrich string and regex generator build failures with native engine diagnostics (hegelExceptionWithDetail).
  • Fix: Throw hegelExceptionWithDetail on FFI failures in stateful_runner.dart instead of continuing with uninitialized out-pointers, and validate rule/invariant names against NUL bytes (\x00).
  • Fix: Propagate machine.tearDown() exceptions in hegelStatefulTest when the stateful body succeeded.
  • Fix: Add package-URI and .dart_tool/package_config.json fallback to loadHegelLibrary() so flutter test resolves 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 reject NaN in tc.cover(), tc.target(), booleans(), and nullable(), as well as non-positive maxAttempts in Generator.where().
  • Fix: Encode sub-second DateTimeGenerator bounds as millisecond * 1000 + microsecond, normalize min/max bounds to UTC via .toUtc(), fix default dateTimes() max bound, and validate bounds/sizes in DateGenerator, TimeGenerator, DateTimeGenerator, and BytesGenerator.
  • Fix: Support nullable Pool<T?> values in stateful testing by checking !_pool.values.containsKey(varId) instead of value == null.
  • Fix: Skip package:flutter_test/, package:flutter/, and package:hegeltest_flutter/ frames and strip surrounding parentheses in extractOrigin.
  • Fix: Replay winning shrunk failure reproduction blobs at the end of HegelRunner.runWithResult when more than one test case ran, clear _caughtExceptions per run, and record qualifying replay exceptions so reports can use the winning replay instead of a rejected shrink probe.
  • API: Export runStateMachine from package: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 least minPercentage% of valid test cases, throwing InsufficientCoverageException if 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 for frequency() matching the oneOf combinator naming convention.
  • New: Export InsufficientCoverageException from 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 during Phase.reuse for instant regression detection.
  • New: Automatic .gitignore created inside .hegel/ to keep developer worktrees clean.
  • New: Opt-out support via database: false parameter or HEGEL_DATABASE=0 environment variable.
  • New: Custom database storage support via databasePath: String.
  • New: example/database_example.dart and comprehensive test/database_test.dart suite.

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 deprecated package:test_api import with package:test.

0.6.1 #

  • Fix: Add runWithResult() to web stub HegelRunner — fixes undefined_method analyzer error in downstream packages (e.g. hegeltest_flutter)

0.6.0 #

  • New: runHegelTest() — standalone property runner that returns RunResult without package:test dependency. 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), and urls() 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.dart registers 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 hooks and code_assets dependencies
  • Graceful handling of unsupported targets (returns empty asset list, no build crash)
  • HEGEL_LIBHEGEL_PATH env 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 on hegeltest: ^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 .sha256 checksum files alongside each binary
  • Binaries are verified before loading — corrupted/tampered files throw StateError with actionable error message

0.2.2 #

  • Fix: Library loader finds native binary in flutter test via package_config.json fallback

0.2.1 #

  • API: Export HegelRunner and loadHegelLibrary for 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 UnsupportedError at runtime)
  • DX: HegelTestFailure extends TestFailure from package: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 reuseBuffer in all combinators + collections
  • Performance: Cache Generator.typeName (was runtimeType.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 outLen bounds check prevents out-of-bounds read
  • Fix: Blob replay now calls setUpEach/tearDownEach and wraps body in zone guard
  • Fix: Late async errors logged to stderr (was silently swallowed)
  • Fix: FilteredGenerator separates predicate rejection from exception in hadError
  • Fix: Collection rejection sets hadError correctly before HegelAssumptionViolated
  • Fix: toString() safety in counterexample formatting (catches throwing toString)
  • Fix: Surrogate-safe truncation via runes.take(200)
  • DX: tearDownEach errors now include full stack trace
  • DX: HegelConfig fields have dartdocs
  • DX: where() accepts maxAttempts parameter (default 100)
  • DX: Reproduce blob validated for NUL bytes before FFI boundary

0.1.0 #

  • Initial release
  • Core hegelTest() integration with package:test
  • 25+ generators: primitives, text, collections, combinators, temporal, network, bytes
  • Generator composition: map(), flatMap(), where(), Generator.composite()
  • HegelConfig for 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
0
likes
160
points
875
downloads

Documentation

API reference

Publisher

verified publisherletstesttools.dev

Weekly Downloads

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.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#testing #property-based-testing #fuzzing #test-generation

License

MIT (license)

Dependencies

code_assets, crypto, ffi, hooks, meta, test, test_api

More

Packages that depend on hegeltest