@@ -6,9 +6,9 @@ import Hedgehog.Gen qualified as Gen
6
6
import Hedgehog.Range qualified as Range
7
7
import LambdaBuffers.Runtime.Plutarch (PList )
8
8
import 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 )
10
10
import Plutarch.Evaluate (evalScript )
11
- import Plutarch.Prelude (PBool (PTrue ), PEq ((#==) ), PInteger , PIsData , pconstant , pif )
11
+ import Plutarch.Prelude (PBool (PTrue ), PEq ((#==) ), PInteger , pconstant , pif )
12
12
import Test.Tasty (TestTree , adjustOption , testGroup )
13
13
import Test.Tasty.HUnit (assertFailure )
14
14
import Test.Tasty.Hedgehog (testProperty )
@@ -19,22 +19,27 @@ test =
19
19
adjustOption (\ _ -> H. HedgehogTestLimit $ Just 1000 ) $
20
20
testGroup
21
21
" 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)" $
23
23
H. property $
24
24
H. forAll
25
25
((,) <$> genInts <*> genInts)
26
26
>>= ( \ (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)
28
28
(xs == ys) H. === b
29
29
)
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
+ )
30
38
]
31
39
where
32
40
genInts :: H. Gen [Integer ]
33
41
genInts = Gen. list (Range. linear 0 100 ) (Gen. integral (Range. linear 0 100 ))
34
42
35
- fromList :: PIsData a => [Term s a ] -> Term s (PList a )
36
- fromList = foldr (\ x -> (#) (Lb. pcons # x)) Lb. pnil
37
-
38
43
evalEq :: ClosedTerm (PList PInteger ) -> ClosedTerm (PList PInteger ) -> IO Bool
39
44
evalEq l r =
40
45
let
0 commit comments