@@ -6,9 +6,9 @@ import Hedgehog.Gen qualified as Gen
66import Hedgehog.Range qualified as Range
77import LambdaBuffers.Runtime.Plutarch (PList )
88import LambdaBuffers.Runtime.Plutarch qualified as Lb
9- import Plutarch (ClosedTerm , Config (Config ), Term , TracingMode (DoTracingAndBinds ), compile , pcon , perror , (#) )
9+ import Plutarch (ClosedTerm , Config (Config ), TracingMode (DoTracingAndBinds ), compile , pcon , perror )
1010import Plutarch.Evaluate (evalScript )
11- import Plutarch.Prelude (PBool (PTrue ), PEq ((#==) ), PInteger , PIsData , pconstant , pif )
11+ import Plutarch.Prelude (PBool (PTrue ), PEq ((#==) ), PInteger , pconstant , pif )
1212import Test.Tasty (TestTree , adjustOption , testGroup )
1313import Test.Tasty.HUnit (assertFailure )
1414import Test.Tasty.Hedgehog (testProperty )
@@ -19,22 +19,27 @@ test =
1919 adjustOption (\ _ -> H. HedgehogTestLimit $ Just 1000 ) $
2020 testGroup
2121 " PList tests"
22- [ testProperty " forall xs :: [Integer] ys :: [Integer]. (xs == ys) === evalEq (toPlutarch xs) (toPlutarch ys)" $
22+ [ testProperty " forall xs :: [Integer] ys :: [Integer]. (xs == ys) === evalEq (plistFrom xs) (plistFrom ys)" $
2323 H. property $
2424 H. forAll
2525 ((,) <$> genInts <*> genInts)
2626 >>= ( \ (xs, ys) -> do
27- b <- liftIO $ evalEq (fromList $ pconstant <$> xs) (fromList $ pconstant <$> ys)
27+ b <- liftIO $ evalEq (Lb. plistFrom $ pconstant <$> xs) (Lb. plistFrom $ pconstant <$> ys)
2828 (xs == ys) H. === b
2929 )
30+ , testProperty " forall xs :: [Integer]. evalEq (plistCase plistCons plistNil (plistFrom xs)) (plistFrom xs)" $
31+ H. property $
32+ H. forAll
33+ genInts
34+ >>= ( \ xs -> do
35+ b <- liftIO $ evalEq (Lb. plistCase Lb. plistCons Lb. plistNil (Lb. plistFrom $ pconstant <$> xs)) (Lb. plistFrom $ pconstant <$> xs)
36+ True H. === b
37+ )
3038 ]
3139 where
3240 genInts :: H. Gen [Integer ]
3341 genInts = Gen. list (Range. linear 0 100 ) (Gen. integral (Range. linear 0 100 ))
3442
35- fromList :: PIsData a => [Term s a ] -> Term s (PList a )
36- fromList = foldr (\ x -> (#) (Lb. pcons # x)) Lb. pnil
37-
3843evalEq :: ClosedTerm (PList PInteger ) -> ClosedTerm (PList PInteger ) -> IO Bool
3944evalEq l r =
4045 let
0 commit comments