1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 17:04:47 +03:00
semantic/test/TermSpec.hs

27 lines
776 B
Haskell
Raw Normal View History

module TermSpec where
import Test.Hspec
import Test.Hspec.QuickCheck
import Data.Text.Arbitrary ()
2016-05-26 20:11:34 +03:00
import Prologue
import Data.String
import Interpreter
import Diff
import ArbitraryTerm
spec :: Spec
spec = parallel $ do
describe "Term" $ do
prop "equality is reflexive" $
\ a -> unTerm a == unTerm (a :: ArbitraryTerm String ())
describe "Diff" $ do
prop "equality is reflexive" $
2016-06-03 09:59:48 +03:00
\ a b -> let diff = diffTerms (free . Free) ((==) `on` extract) diffCost (unTerm a) (unTerm (b :: ArbitraryTerm String CategorySet)) in
diff == diff
prop "equal terms produce identity diffs" $
\ a -> let term = unTerm (a :: ArbitraryTerm String CategorySet) in
2016-06-03 09:59:48 +03:00
diffCost (diffTerms (free . Free) ((==) `on` extract) diffCost term term) == 0