about summary refs log tree commit diff
path: root/test/Xanthous/Generators/UtilSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Xanthous/Generators/UtilSpec.hs')
-rw-r--r--test/Xanthous/Generators/UtilSpec.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/Xanthous/Generators/UtilSpec.hs b/test/Xanthous/Generators/UtilSpec.hs
index a1c2f79d60..c82c385987 100644
--- a/test/Xanthous/Generators/UtilSpec.hs
+++ b/test/Xanthous/Generators/UtilSpec.hs
@@ -41,7 +41,7 @@ test = testGroup "Xanthous.Generators.Util"
                 $ randInitialize dims aliveChance
         in bounds res === ((0, 0), (dims ^. width, dims ^. height))
     ]
-  , testGroup "numAliveNeighbors"
+  , testGroup "numAliveNeighborsM"
     [ testProperty "maxes out at 8" $ \(GenArray (arr :: Array (Word, Word) Bool)) loc ->
         let
           act :: forall s. ST s Word
@@ -51,6 +51,17 @@ test = testGroup "Xanthous.Generators.Util"
           res = runST act
         in counterexample (show res) $ between 0 8 res
     ]
+  , testGroup "numAliveNeighbors"
+    [ testProperty "is equivalient to runST . numAliveNeighborsM . thaw" $
+      \(GenArray (arr :: Array (Word, Word) Bool)) loc ->
+        let
+          act :: forall s. ST s Word
+          act = do
+            mArr <- thaw @_ @_ @_ @(STUArray s) arr
+            numAliveNeighborsM mArr loc
+          res = runST act
+        in numAliveNeighbors arr loc === res
+    ]
   , testGroup "cloneMArray"
       [ testCase "clones the array" $ runST $
           let