OrderSpec.hs 1.19 KB
Newer Older
Sven Keidel's avatar
Sven Keidel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
{-# LANGUAGE OverloadedStrings #-}
module OrderSpec(main, spec) where

import qualified WildcardSemantics as A
import           Data.Order
import           Data.Result
import qualified Data.HashMap.Lazy as M
import qualified Data.Powerset as P
import qualified Data.AbstractPowerset as A

import           Test.Hspec

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
  
  it "ordering on abstract powersets is correct" $
    ( pow [Success (A.Cons "f" [A.Cons "g" [], A.Cons "h" []]), Fail]  pow [Success A.Wildcard, Fail] )
         `shouldBe` True

  it "ordering on environments" $
    termEnv [("x",A.Cons "f" []), ("y",A.Cons "g" [])]  termEnv [("x",A.Wildcard)] 
         `shouldBe` True

  it "ordering of abstract powersets of results is correct" $ do
    pow [Fail]  pow [Success (A.Wildcard,termEnv []), Fail]
         `shouldBe` True

    pow [Success (A.Cons "g" [], termEnv [])]  pow [Success (A.Wildcard,termEnv []), Fail]
         `shouldBe` True

    pow [Success (A.Wildcard, termEnv [])]  pow [Success (A.Cons "g" [],termEnv []), Fail]
         `shouldBe` False

  where
    termEnv = A.TermEnv . M.fromList
    pow :: Foldable f => f a -> A.Pow a
    pow = P.fromFoldable