Repository navigation
Releases
v2.8.1
- Make
CorpusStoragewrites atomic and serialise the read-modify-write in
remember()/prune()with a cross-process flock. Without this, two
concurrent writers (e.g.infection --threads=max, parallel CI jobs sharing
a corpus dir) could each read the same on-disk state and the second commit
would silently lose the first; and a process killed mid-write would leave a
truncated JSON document that the nextrecall()silently drops. Writes now
go through a temp file + atomicrename(), so a reader sees either the
previous or the new document, never a partial one. A short write (full disk)
or a failedrename()aborts the commit and keeps the previous document
intact instead of renaming a truncated temp file over it; a failedflock()
raises instead of silently proceeding unserialised. - Run the Unit suite on Windows in CI.
v2.8.0
Regression corpus. PROPERTY_DB graduates from "remember the last failing seed"
to a small per-property corpus of past failures, stored as data wherever
possible.
- A falsified property now records its minimised input, not just a seed.
When every shrunk argument is representable as data —null, scalars, arrays,
enum cases, byte strings — the input itself is stored and replayed as a single
run, reported through the new@apiRegressionViolationException
(getArguments(),getSeed()). Such an entry costs one run instead of a whole
random phase and keeps reproducing the bug even when the generation sequence
shifts. Counterexamples that cannot be represented (objects, closures, in-body
Gen::draw()values) still fall back to storing the seed and replay the random
phase as before. - Several failures per property. The corpus keeps up to 8 values entries and
2 seed entries (oldest evicted, duplicates collapsed) and replays them all
before the random phase, so fixing the newest regression no longer forgets the
older ones. An entry that no longer fails — or that the property now discards
viaAssume::that()— is pruned. - Stale entries are dropped instead of misreported. A values entry whose
argument names no longer match the property's signature (renamed, reordered or
added parameter) and a seed entry from a superseded generation-sequence epoch
are both discarded rather than replayed as a different input. The on-disk
format carries a version and is ignored wholesale when it is not the expected
one. - Storage moved from
<sha1(id)>.seedto<sha1(id)>.json. A corpus directory
written by an earlier version is not read; it is an opt-in local cache and
regenerates on the next failure.
v2.7.1
- Reject trailing newlines in validated values: anchor regexes with
\z
instead of$inCounterExample::toExamplesCode()(the examples-method
name passed to the reflection/replay path) and inPropertyInterceptor/
SeedStorageinteger parsers. The latter two are hygiene only — env values
andtrim()'ed seed-file contents already strip the newline before the
regex runs.
v2.7.0
v2.6.0
- Psalm generics across the public surface:
ArbitraryInterface<TValue>,
Shrinkable<TValue>, all built-in arbitraries, and theGenfacade typed
end-to-end — consumer code gets inference (Gen::map(Gen::intBetween(0, 5), fn(int $n): string => ...)isArbitraryInterface<string>) and closure
parameters check against the inner arbitrary's type. Docblock-only; runtime
behaviour is unchanged. - Counterexample messages gain a
Changed:line diffing the original against
the shrunk arguments (unchanged arguments omitted) and a trial count next to
the accepted shrink steps:(12 shrink step(s), 41 trial(s)). CounterExampleexposesshrinkTrials— the total number of shrink
candidates tried (accepted and rejected); included intoArray()/toJson().PROPERTY_VERBOSEnow also traces the shrink descent: one line per accepted
candidate (shrink step 3: x=63 -> 51), includingdraw#Ntape positions.#[Property(timeoutMs:)]— opt-in wall-clock deadline for a single run
(random or example). A body that takes longer fails the property with a new
DeadlineExceededExceptionnaming the offending input — protection against
pathological inputs (catastrophic regex, deep recursion, unbounded backoff).
Measured post-run; the input is reported unshrunk.#[Property(budgetMs:)]— opt-in wall-clock budget for the whole random
phase. Running out before the requested checks complete fails the property
with a newTimeBudgetExceededExceptionexposing completed/required run
counts.
v2.5.0
Correctness release. Generators never hand a property an out-of-domain value,
and a property that checks nothing no longer passes silently. Behaviour changes
below are bug fixes, but observable — review if you relied on the old behaviour.
Gen::filter()now throwsGenerationExhausted(new@apiexception)
after 100 rejected draws, instead of returning the last (predicate-failing)
value. The interceptor catches it at the generation step and reports a clean
failure. Exhaustion can be transient (a satisfiable-but-rare predicate) — widen
the source, raise the budget, or useGen::flatMap()for dependent domains.runsnow means successful checks. Discarded attempts do not consume the
requested run count. The new trailingProperty::$maxDiscardsoption bounds
retries (default:runs * 10); exceeding it fails withGaveUpException,
which exposes required/successful/discarded/attempt counts.- Sized collections guarantee their minimum.
Gen::dictOf()now keeps
distinct keys (was: colliding keys overwrite) andGen::commands()throws when
no applicable command reaches$minLength; both, plusGen::uniqueArrayOf(),
now signal an unreachable minimum withGenerationExhausted.
Gen::uniqueArrayOf()previously threwInvalidArgumentExceptionfor this case
— the type changed toGenerationExhausted(extendsRuntimeException). - Counterexamples render nested values. Arrays and objects are shown
recursively (bounded depth/width/length, special floats and binary strings
labelled, object cycles guarded) instead of[N element(s)]/ a bare class
name — inPropertyViolationException,ExampleViolationExceptionand the
verbose run log. Object rendering includes private/protected properties (real
DTOs across their inheritance chain), and strings, map keys andStringable
output are escaped and bounded so a value stays on one unambiguous line.
CounterExample::toArray()/toJson()provide machine-readable output;
toExamplesCode()produces a runnable examples-method fragment for values
that PHP can represent directly. - Removed the unsupported
Attribute::TARGET_FUNCTIONfrom#[Property]; it only
ever ran on methods.
v2.4.0
In-body dependent draw (T2.5). Additive, no BC breaks; existing seed sequences
are unchanged (a property that never calls Gen::draw() generates exactly the
same values as before).
-
Fix: aggregate property results now carry the per-run
TestResult
attributes (merged run-by-run, last write per key wins) on all paths —
passed, falsified, coverage violation and failing explicit example.
Previously the interceptor returned a bareTestResult, dropping
attributes attached by downstream interceptors — notably Testo codecov's
CoverageResult, so property tests were missing from per-test coverage
(<covered by>), and mutation-testing tools like Infection never selected
them when running mutants: mutants on lines covered only by property tests
escaped silently. -
Add
Gen::draw($arbitrary)— generate a value inside the property body when
several dependent values make nestedflatMapawkward. The domain may depend
on parameters, previous draws, or intermediate results. -
Drawn values shrink together with the parameters via a replay tape: every
draw is recorded as aShrinkable, shrunk through its own tree, and the body
is re-run with the tape replayed by position. Draws past the tape's end
(control flow changed under a smaller prefix) are generated anew; draws the
smaller run no longer reaches are dropped. -
Counterexamples report draws as
draw#1,draw#2, ... next to the named
parameters;PROPERTY_VERBOSEadditionally logs each run's draws. -
With draws present, accepted shrink steps are capped at 1000 (an explicit
maxShrinksstill wins) — a regrown tape carries fresh trees, so the
finite-tree termination argument alone no longer applies. -
Gen::draw()outside a property run throws aRuntimeException. Explicit
examples may draw too (their draws come from a dedicated deterministic
stream).
v2.3.0
Generator catalog, explicit examples and seed persistence (Waves 5–6, excluding
in-body draw). Additive, no BC breaks; existing seed sequences are unchanged.
- Add domain arbitraries:
Gen::ipv4(),Gen::email(),Gen::url(),
Gen::json()/Gen::jsonString(), andGen::regex()/
Gen::stringMatching().regexcompiles a regular-expression subset
(literals,., classes[...],\d\w\sand negations, quantifiers
* + ? {n} {n,} {n,m}, alternation, groups) into ordinary combinators, so
matches shrink through the existing trees. Unsupported constructs (anchors
other than a single leading^/trailing$, backreferences, lookaround,
named/inline groups, flags) throw, naming the construct. - Add explicit examples:
#[Property(examples: 'method')]or a
<testMethod>Examplesconvention method returns fixed positional argument
tuples, each run before the random inputs and not shrunk. A failing example is
reported viaExampleViolationException. - Add opt-in regression replay: when
PROPERTY_DBnames a directory, a
falsified property records its failing seed and re-runs it first on the next
run (unless the attribute pins a seed). Only the seed is stored. - In-body draw (
Gen::draw(), roadmap T2.5) is deferred to 2.4.0: it needs a
replay-tape shrink mechanism that the per-arbitrary tree model lacks.
v2.2.0
Stateful / model-based testing (Wave 4); additive, no BC breaks, seed sequences
of existing generators are unchanged.
- Add stateful / model-based testing in the new
Rasuvaeff\PropertyTesting\StateMachine
namespace: theCommandinterface (preCondition/nextState/run/postCondition,
\Stringablelabel),Gen::commands($initialModel, $commandGenerators, $minLength, $maxLength)
producing aCommandSequencearbitrary, andStateMachine::check($sequence, $systemFactory)
to drive the sequence against a fresh system under test. Generated sequences are
valid by construction; shrinking drops command blocks (down to a single command,
isolating a failing middle step) and simplifies each command's parameters. A failed
postcondition throwsPostconditionViolationnaming the failing step and trace. - Render
\Stringablearguments via__toString()in counterexamples and verbose
logs (previously objects showed only their class name). - Report the failure of the shrunk run in the counterexample, not the original
draw — theFailure:line now matches the minimisedShrunk:arguments.
v2.1.0
Consumer-driven additions (Wave 3); no BC breaks, seed sequences of existing
generators are unchanged.
- Add
Classify::cover($condition, $label, $minPercent): a coverage
requirement — the property fails with the newCoverageViolationException
when the label occurs in fewer than$minPercentof passing runs, making
vacuous passes a CI failure instead of a printed hint. - Add
Gen::stringFrom($alphabet, $min, $max)(CharsetStringArbitrary):
strings over a fixed (possibly multibyte) alphabet; shrinks by length, then
each character toward the first alphabet character. - Add
Gen::bytes($min, $max)(BytesArbitrary): raw byte strings for
parsers/codecs; shrinks by length, then each byte toward"\x00". - Add
Gen::enum(SomeEnum::class): one enum case, shrinking toward
earlier-declared cases. - Add
Gen::uniqueArrayOf($element, $min, $max)(UniqueArrayArbitrary):
lists of pairwise-distinct elements; shrinking preserves distinctness. - Add
Gen::intRange($min, $max): ordered pairs[lo, hi]withlo <= hi
built onflatMap, replacingAssume::that()discards for intervals. - Add
Gen::floatSpecial(): opt-inNAN/±INF/-0.0/representation-edge
floats (the defaultfloat()/floatBetween()stay finite and in range). - Add
Gen::recursive($leaf, $wrap, $maxDepth): bounded recursive structures
built by lifting the previous level's arbitrary. - Add
Gen::sampleShrinks(): generate one value and list its first shrink
candidates — a debugging aid for custom arbitraries. - Add optional size bounds to
Gen::arrayOf(),Gen::nonEmptyArrayOf()and
Gen::dictOf(). - Honour
PROPERTY_VERBOSEto log every run's generated arguments.