is that enough

This commit is contained in:
Antonis Geralis 2022-09-14 13:25:09 +03:00
parent 5b4c0d0585
commit 1ec36d3fb7
1 changed files with 10 additions and 13 deletions

View File

@ -424,7 +424,11 @@ proc runMutator*[T: SomeNumber](x: var T; sizeIncreaseHint: int; enforceChanges:
mutate(x, sizeIncreaseHint, enforceChanges, r)
proc runMutator*[T](x: var seq[T]; sizeIncreaseHint: int; enforceChanges: bool; r: var Rand) =
mutate(x, sizeIncreaseHint, enforceChanges, r)
var res = 0
var s: Sampler[int]
sample(x, s, r, res)
res = s.selected
pick(x, sizeIncreaseHint, enforceChanges, r, res)
proc runMutator*(x: var string; sizeIncreaseHint: int; enforceChanges: bool; r: var Rand) =
mutate(x, sizeIncreaseHint, enforceChanges, r)
@ -467,13 +471,6 @@ proc runMutator*[T](x: var ref T; sizeIncreaseHint: int; enforceChanges: bool; r
runMutator(x[], sizeIncreaseHint, enforceChanges, r)
proc runMutator*[S, T](x: var array[S, T]; sizeIncreaseHint: int; enforceChanges: bool; r: var Rand) =
mixin default
when compiles(mutate(x, sizeIncreaseHint, enforceChanges, r)):
mutate(x, sizeIncreaseHint, enforceChanges, r)
else:
if not enforceChanges and rand(r, RandomToDefaultRatio - 1) == 0:
x = default(typeof(x))
else:
var res = 0
var s: Sampler[int]
sample(x, s, r, res)