summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/GenomeTest.hs29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/GenomeTest.hs b/test/GenomeTest.hs
index aa6d310..2222347 100644
--- a/test/GenomeTest.hs
+++ b/test/GenomeTest.hs
@@ -2,7 +2,8 @@ module GenomeTest (suite) where
import Test.Tasty
import Test.Tasty.HUnit
-import Mind (NeuronIndex (..))
+import Mind (Edge (..), NeuronIndex (..))
+import qualified Mind as N (Network (..))
import Genome
import System.Random
import Data.Ix
@@ -204,4 +205,30 @@ mutationTests = testGroup "mutations" $
[ Gene { source = Internal 0, sink = Internal 1, weight = 1.0 }
, Gene { source = Internal 2, sink = Output 0, weight = 1.0 }
]
+ , testCase "parse genome into network" $
+ let
+ 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 = 2.0 }
+ , Gene { source = Internal 1, sink = Internal 2, weight = 3.0 }
+ , Gene { source = Internal 2, sink = Output 0, weight = 4.0 }
+ ]
+ }
+ network = parseGenome genome
+ expected = N.Network
+ { N.numInput = 1
+ , N.internalNeurons =
+ [ [ Edge (Input 0, 1.0) ]
+ , [ Edge (Internal 0, 2.0) ]
+ , [ Edge (Internal 1, 3.0) ]
+ ]
+ , N.outputNeurons =
+ [ [ Edge (Internal 2, 4.0) ]
+ ]
+ }
+ in network @?= expected
]