Hasty Briefsbeta

Bilingual

256 Lines or Less: Test Case Minimization

14 hours ago
  • A simple Property-Based Testing (PBT) library is implemented in just 256 lines of Zig, using a Finite Random Number Generator (FRNG) that pre-generates all random numbers and can run out of entropy.
  • The FRNG provides built-in functions for generating bytes, arrays, integers, booleans, bounded integers, and slice indices, with compile-time polymorphism for flexibility.
  • The library is used for simulation testing by feeding random inputs to a system under test, crashing on any inconsistency, and the finite entropy allows for automatic test case minimization via binary search to find the smallest failing input.
  • The test harness spawns a separate process for the system under test, passes entropy via stdin, and uses a seed+size approach to reproduce runs.
  • The search algorithm doubles the step size to find a failure, then halves to minimize the entropy size, outputting the minimal failing seed and size for debugging.