summaryrefslogtreecommitdiff
path: root/test/LatticeTest.hs
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-29 20:48:46 -0600
committersanine <sanine.not@pm.me>2023-11-29 20:48:46 -0600
commit587cbadb3e6388c29454ab41c120757f108918fa (patch)
tree1fae09c76fce21b3f1b4ff23653dc5aa2f9067ac /test/LatticeTest.hs
parent4facdd8a1a5f141b158acbe1959da3d10d4c8ce9 (diff)
implement updateLattice
Diffstat (limited to 'test/LatticeTest.hs')
-rw-r--r--test/LatticeTest.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/LatticeTest.hs b/test/LatticeTest.hs
new file mode 100644
index 0000000..a7d67d8
--- /dev/null
+++ b/test/LatticeTest.hs
@@ -0,0 +1,37 @@
+module LatticeTest (suite) where
+
+import Test.Tasty
+import Test.Tasty.HUnit
+import Lattice
+
+suite :: TestTree
+suite = testGroup "lattice tests" $
+ [ latticeGrowth
+ ]
+
+
+data GrowKind = Empty | Plant deriving (Show, Enum, Eq)
+data GrowFlags = None deriving (Show, Eq)
+
+
+latticeGrowth :: TestTree
+latticeGrowth = testCase "growth update rule" $
+ let
+ plant = LatticeCell Plant None
+ empty = LatticeCell Empty None
+ lattice = [[ empty, empty, plant ]]
+ rules =
+ [
+ -- empty
+ \l x y ->
+ if kind ((l !! y) !! (x+1)) == Plant
+ then LatticeCell Plant None
+ else LatticeCell Empty None
+ -- plant
+ , \_ _ _ -> LatticeCell Plant None
+ ] :: [LatticeRule GrowKind GrowFlags]
+ lattice' = updateLattice lattice rules
+ lattice'' = updateLattice lattice' rules
+ in do
+ lattice' @?= [[ empty, plant, plant ]]
+ lattice'' @?= [[ plant, plant, plant ]]