Skip to content

Commit

Permalink
Add test case for joinBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
msooseth committed Jan 6, 2025
1 parent 7f40a15 commit f306e9c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ tests = testGroup "hevm"
, testProperty "simplifyProp-equivalence-sym" $ \(p) -> prop $ do
let simplified = Expr.simplifyProp p
checkEquivPropAndLHS p simplified
, testProperty "simplify-joinbytes" $ \(SymbolicJoinBytes exprList) -> prop $ do
let x = joinBytesFromList exprList
let simplified = Expr.simplify x
y <- checkEquiv x simplified
assertBoolM "Must be equal" y
, testProperty "simpProp-equivalence-sym-Prop" $ \(ps :: [Prop]) -> prop $ do
let simplified = pand (Expr.simplifyProps ps)
checkEquivPropAndLHS (pand ps) simplified
Expand Down Expand Up @@ -4012,6 +4017,23 @@ instance Arbitrary (Expr EWord) where
instance Arbitrary (Expr Byte) where
arbitrary = sized genByte

newtype SymbolicJoinBytes = SymbolicJoinBytes [Expr Byte]
deriving (Eq, Show)

instance Arbitrary SymbolicJoinBytes where
arbitrary = liftM SymbolicJoinBytes $ replicateM 32 arbitrary

joinBytesFromList :: [Expr Byte] -> Expr EWord
joinBytesFromList [a0, a1, a2, a3, a4, a5, a6, a7,
a8, a9, a10, a11, a12, a13, a14, a15,
a16, a17, a18, a19, a20, a21, a22, a23,
a24, a25, a26, a27, a28, a29, a30, a31] =
JoinBytes a0 a1 a2 a3 a4 a5 a6 a7
a8 a9 a10 a11 a12 a13 a14 a15
a16 a17 a18 a19 a20 a21 a22 a23
a24 a25 a26 a27 a28 a29 a30 a31
joinBytesFromList _ = internalError "List must contain exactly 32 elements"

instance Arbitrary (Expr Buf) where
arbitrary = sized defaultBuf

Expand Down

0 comments on commit f306e9c

Please sign in to comment.