Skip to content

Commit

Permalink
clean up simplification tests, now very pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
raehik committed Oct 11, 2024
1 parent 7b5943a commit 348a676
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions test/Main.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE AllowAmbiguousTypes #-}

module Main where

import Test.TypeSpec hiding ( And )
Expand All @@ -6,25 +8,37 @@ import Rerefined.Predicates
import Rerefined.Predicate
import TypeLevelShow.Utils ( type (++) )

-- | Pretty opaque predicate for simplification proofs.
data Opaque
instance Predicate Opaque where type PredicateName d Opaque = "p"

-- | Shorthand for the pretty opaque predicate.
type P = Opaque

main :: IO ()
main = print spec

spec :: Expect
(And Fail Succeed `SimplifiesTo` Fail
-/- And Succeed Fail `SimplifiesTo` Fail
-/- And Succeed Succeed `SimplifiesTo` Succeed
-/- And Fail Fail `SimplifiesTo` Fail

-/- Or Succeed Fail `SimplifiesTo` Succeed
-/- Or Fail Succeed `SimplifiesTo` Succeed
-/- Or Succeed Succeed `SimplifiesTo` Succeed
-/- Or Fail Fail `SimplifiesTo` Fail
-- AND identity laws
(And Fail P `SimplifiesTo` Fail
-/- And P Fail `SimplifiesTo` Fail
-/- And Succeed P `SimplifiesTo` P
-/- And P Succeed `SimplifiesTo` P

-- OR identity laws
-/- Or Succeed P `SimplifiesTo` Succeed
-/- Or P Succeed `SimplifiesTo` Succeed
-/- Or Fail P `SimplifiesTo` P
-/- Or P Fail `SimplifiesTo` P

-- other
-/- And (CompareLength RelOpLT 3) (CompareLength RelOpGT 3)
`SimplifiesTo` Fail
)
spec = Valid

-- | TODO I'd like to write my own message here, but type-spec is complicated.
-- | TODO I'd like to write my own failure message here, but type-spec is
-- complicated.
type SimplifiesTo p p' = It
(PredicateName 0 p ++ " simplifies to " ++ PredicateName 0 p')
(TrySimplify p `Is` Just p')

0 comments on commit 348a676

Please sign in to comment.