diff --git a/test/unit/check/runner/Runner.spec.ts b/test/unit/check/runner/Runner.spec.ts index a5e919f3d4e..165561de792 100644 --- a/test/unit/check/runner/Runner.spec.ts +++ b/test/unit/check/runner/Runner.spec.ts @@ -4,6 +4,7 @@ import * as fc from '../../../../lib/fast-check'; import Shrinkable from '../../../../src/check/arbitrary/definition/Shrinkable'; import IProperty from '../../../../src/check/property/IProperty'; import { check, assert as rAssert } from '../../../../src/check/runner/Runner'; +import MutableRandomGenerator from '../../../../src/random/generator/MutableRandomGenerator'; const MAX_NUM_RUNS = 1000; describe('Runner', () => { @@ -89,6 +90,28 @@ describe('Runner', () => { return true; }) )); + it('Should generate the same values given the same seeds', () => fc.assert( + fc.property(fc.integer(), (seed) => { + const buildPropertyFor = function(runOn: number[]) { + const p: IProperty<[number]> = { + generate: (rng: MutableRandomGenerator) => { + return new Shrinkable([rng.next()[0]]) as Shrinkable<[number]>; + }, + run: (value: [number]) => { + runOn.push(value[0]); + return null; + } + }; + return p; + } + let data1: number[] = []; + let data2: number[] = []; + check(buildPropertyFor(data1), {seed: seed}); + check(buildPropertyFor(data2), {seed: seed}); + assert.deepEqual(data2, data1, 'Should run on the same values given the same seed'); + return true; + }) + )); }); describe('assert', () => { const v1 = { toString: () => "toString(value#1)" };