distincts are much faster than ranges

This commit is contained in:
Antonis Geralis 2022-09-14 15:18:32 +03:00
parent 6d750ded81
commit bc7877826a
1 changed files with 17 additions and 0 deletions

17
tests/tarrays2.nim Normal file
View 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)