diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/GenomeTest.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/GenomeTest.hs b/test/GenomeTest.hs index d775467..aa6d310 100644 --- a/test/GenomeTest.hs +++ b/test/GenomeTest.hs @@ -175,4 +175,33 @@ mutationTests = testGroup "mutations" $ validSource (source new) @?= True validSink (sink new) @?= True (w >= -4) && (w <= 4) @?= True + , testCase "remove a gene" $ + let + r = mkStdGen 1 -- randomR (0, 2) produces (1, 2, 0, ...) + genome = Genome + { numInput = 1 + , numInternal = 3 + , numOutput = 1 + , genes = + [ Gene { source = Input 0, sink = Internal 0, weight = 1.0 } + , Gene { source = Internal 0, sink = Internal 1, weight = 1.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } + ] + } + (genome', r') = mutateGenomeRemoveGene genome r + (genome'', r'') = mutateGenomeRemoveGene genome r' + (genome''', _) = mutateGenomeRemoveGene genome r'' + in do + genes genome' @?= + [ Gene { source = Input 0, sink = Internal 0, weight = 1.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } + ] + genes genome'' @?= + [ Gene { source = Input 0, sink = Internal 0, weight = 1.0 } + , Gene { source = Internal 0, sink = Internal 1, weight = 1.0 } + ] + genes genome''' @?= + [ Gene { source = Internal 0, sink = Internal 1, weight = 1.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } + ] ] |