mirror of
https://github.com/status-im/nim-drchaos.git
synced 2025-02-17 21:37:35 +00:00
distincts are much faster than ranges
This commit is contained in:
parent
6d750ded81
commit
bc7877826a
17
tests/tarrays2.nim
Normal file
17
tests/tarrays2.nim
Normal file
@ -0,0 +1,17 @@
|
||||
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)
|
Loading…
x
Reference in New Issue
Block a user