nim-drchaos/tests/tarrays2.nim

18 lines
442 B
Nim
Raw Normal View History

2022-09-14 12:18:32 +00:00
import drchaos/mutator, std/random
const
MaxFaces = 6
type
DiceFace = distinct int #range[1..6]
proc `==`(a, b: DiceFace): bool {.borrow.}
proc mutate(value: var DiceFace; sizeIncreaseHint: int; enforceChanges: bool; r: var Rand) =
repeatMutate(DiceFace(mutateEnum(value.int, MaxFaces, r)+1))
func fuzzTarget(x: array[10, DiceFace]) =
doAssert x != array[10, DiceFace]([1, 6, 2, 3, 4, 3, 6, 4, 5, 2])
defaultMutator(fuzzTarget)