From fad0eadb729528918a6e2762c9a026abb3c821b6 Mon Sep 17 00:00:00 2001 From: martyall Date: Sat, 4 May 2024 15:30:55 -0700 Subject: [PATCH] fix test --- factors/test/Main.hs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/factors/test/Main.hs b/factors/test/Main.hs index 1500ab3..7eff9cd 100644 --- a/factors/test/Main.hs +++ b/factors/test/Main.hs @@ -8,23 +8,20 @@ import Test.QuickCheck import ZK.Factors (Factors (..), Fr, factors) main :: IO () -main = do +main = hspec $ do let circuit = factorsCircuit $ factors @Fr vars = factorsVars $ factors @Fr - print circuit - print vars - hspec $ do - describe "Factors" $ do - it "should accept valid factors" $ do - property $ - \x y -> - let inputs = assignInputs vars $ Map.fromList [("n", x * y), ("a", x), ("b", y)] + describe "Factors" $ do + it "should accept valid factors" $ do + property $ + \x y -> + let inputs = assignInputs vars $ Map.fromList [("n", x * y), ("a", x), ("b", y)] + w = solve vars circuit inputs + in lookupVar vars "out" w === Just 1 + it "shouldn't accept invalid factors" $ do + property $ + \x y z -> + (x * y /= z) ==> + let inputs = assignInputs vars $ Map.fromList [("n", z), ("a", x), ("b", y)] w = solve vars circuit inputs - in lookupVar vars "out" w === Just 1 - it "shouldn't accept invalid factors" $ do - property $ - \x y z -> - (x * y /= z) ==> - let inputs = assignInputs vars $ Map.fromList [("n", z), ("a", x), ("b", y)] - w = solve vars circuit inputs - in lookupVar vars "out" w == Just 0 + in lookupVar vars "out" w == Just 0