@@ -337,24 +337,84 @@ let genTests = testList "Gen tests" [
337337 secondValues.Count > 10 |> Expect.isTrue
338338 thirdValues.Count > 10 |> Expect.isTrue
339339
340+ // The concrete value of the snapshot is unimportant.
341+ // However, if this value changes it may be because you may have broken determinism.
342+ let snapshot = {
343+ Value = 14141672759607663454 UL
344+ Gamma = 16294208416658607535 UL
345+ }
346+
340347 testCase " Seed is deterministic" <| fun () ->
341348 // `checkBoolWith` should always produce the same result for the same starting seed.
342- // The concrete value of the snapshot is unimportant.
343- // However, if this value changes it may be because you may have broken determinism.
344- let snapshot =
345- { Value = 14141672759607663454 UL
346- Gamma = 16294208416658607535 UL }
349+ let config =
350+ PropertyConfig.defaults
351+ |> PropertyConfig.withSeed ( Seed.from 0 UL)
352+ |> PropertyConfig.withTests 1 < tests>
347353
354+ Property.checkBoolWith config <| property {
355+ let! x =
356+ Random.seed
357+ |> Random.map Tree.singleton
358+ |> Gen.ofRandom
359+
360+ return x = snapshot
361+ }
362+
363+ testCaseAsync " Seed is deterministic async" <| async {
364+ // `checkBoolAsyncWith` should always produce the same result for the same starting seed.
348365 let config =
349366 PropertyConfig.defaults
367+ |> PropertyConfig.withSeed ( Seed.from 0 UL)
350368 |> PropertyConfig.withTests 1 < tests>
351369
370+ do !
371+ Property.checkBoolAsyncWith config <| property {
372+ let! x =
373+ Random.seed
374+ |> Random.map Tree.singleton
375+ |> Gen.ofRandom
376+
377+ return x = snapshot
378+ }
379+ }
380+
381+ testCase " withRandomSeed differs from fixed-seed behavior" <| fun () ->
382+ let config =
383+ PropertyConfig.defaults
384+ |> PropertyConfig.withRandomSeed
385+ |> PropertyConfig.withTests 10 < tests>
386+
352387 Property.checkBoolWith config <| property {
353388 let! x =
354389 Random.seed
355390 |> Random.map Tree.singleton
356391 |> Gen.ofRandom
357392
393+ return x <> snapshot
394+ }
395+
396+ testCase " recheck path preserves configured seed semantics" <| fun () ->
397+ let config =
398+ PropertyConfig.defaults
399+ |> PropertyConfig.withSeed ( Seed.from 123 UL)
400+ |> PropertyConfig.withTests 1 < tests>
401+
402+ // The concrete value of the snapshot is unimportant.
403+ // However, if this value changes it may be because you may have broken determinism.
404+ let snapshot = {
405+ Value = 16826716191977273598 UL
406+ Gamma = 13032462758197477675 UL
407+ }
408+
409+ let p = property {
410+ let! x =
411+ Random.seed
412+ |> Random.map Tree.singleton
413+ |> Gen.ofRandom
414+
358415 return x = snapshot
359416 }
417+
418+ Property.checkBoolWith config p
419+ Property.recheckBoolWith " 0_9208534749291869864_13032462758197477675_" config p
360420]
0 commit comments