diff options
author | sanine <sanine.not@pm.me> | 2023-11-29 12:12:46 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-29 12:12:46 -0600 |
commit | fa28b97de15b00946788f4f78cf932bc202f4811 (patch) | |
tree | af8a1a86671beeb2eb66c382ceaf7d5f22a378a4 /test/GenomeTest.hs | |
parent | a506d45e16922bbda123f92dad55959694ccc2df (diff) |
rewrite genome tests to use approximate float comparison
Diffstat (limited to 'test/GenomeTest.hs')
-rw-r--r-- | test/GenomeTest.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/GenomeTest.hs b/test/GenomeTest.hs index 0a27a94..a09e742 100644 --- a/test/GenomeTest.hs +++ b/test/GenomeTest.hs @@ -62,11 +62,17 @@ mutationTests = testGroup "mutations" $ ) ([], rand) (replicate 3 sourceGene) - in - mutatedGenes @?= - [ Gene { source = M.Input 0, sink = M.Output 1, weight = 7.572357} - , Gene { source = M.Input 0, sink = M.Output 1, weight = -1.4116564 } - , Gene { source = M.Input 0, sink = M.Internal 1, weight = -7.2413177 } - ] - + expected = + [ Gene { source = M.Input 0, sink = M.Output 1, weight = 7.572357} + , Gene { source = M.Input 0, sink = M.Output 1, weight = -1.4116564 } + , Gene { source = M.Input 0, sink = M.Output 1, weight = -7.2413177 } + ] + approxEqual a b = abs (a-b) < 0.0001 + in do + (map source mutatedGenes) @?= (map source expected) + (map sink mutatedGenes) @?= (map sink expected) + True @?= foldl (&&) True (zipWith approxEqual + (map weight mutatedGenes) + (map weight expected) + ) ] |