From b2a8a61b287d232db8dcbb78c9e4a88ab7b8c2a7 Mon Sep 17 00:00:00 2001
From: sanine <sanine.not@pm.me>
Date: Fri, 8 Dec 2023 14:21:19 -0600
Subject: prevent applying invalid proposals

---
 test/LatticeTest.hs | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

(limited to 'test/LatticeTest.hs')

diff --git a/test/LatticeTest.hs b/test/LatticeTest.hs
index 9edff30..40c0a85 100644
--- a/test/LatticeTest.hs
+++ b/test/LatticeTest.hs
@@ -94,7 +94,7 @@ proposalApplication = testGroup "apply proposal lists to lattices" $
     in
       lattice' @?= [
         [ LatticeCell Plant (Just False)
-        , LatticeCell Plant (Just True)
+        , LatticeCell Plant Nothing -- reset by the application process
         , LatticeCell Plant (Just True)
         ]
       ]
@@ -113,5 +113,19 @@ proposalApplication = testGroup "apply proposal lists to lattices" $
         [ LatticeCell Plant (MergeInt $ 0-6)
         ]
       ]
+  , testCase "invalid proposals are not applied" $
+    let
+      plant = LatticeCell Plant Nothing
+      empty = LatticeCell Empty Nothing
+      lattice = [[ empty, plant, empty ]]
+      proposals :: LatticePropList GrowKind (Maybe Bool)
+      proposals = LatticePropList
+        [ LatticeProposal (0, 0) Plant Plant Nothing
+        , LatticeProposal (1, 0) Plant Empty Nothing
+        , LatticeProposal (2, 0) Empty Plant Nothing
+        ]
+      lattice' = applyLatticeProposals lattice proposals
+    in
+      lattice' @?= [[ empty, empty, plant ]]
 
   ]
-- 
cgit v1.2.1