2015-12-17 21:08:47 +03:00
|
|
|
module TermSpec where
|
|
|
|
|
|
|
|
import Test.Hspec
|
|
|
|
import Test.Hspec.QuickCheck
|
2015-12-18 23:03:54 +03:00
|
|
|
import Data.Text.Arbitrary ()
|
2015-12-17 21:08:47 +03:00
|
|
|
|
2016-05-26 20:11:34 +03:00
|
|
|
import Prologue
|
|
|
|
import Data.String
|
2015-12-17 21:08:47 +03:00
|
|
|
import Interpreter
|
|
|
|
import Diff
|
2015-12-22 20:53:31 +03:00
|
|
|
import ArbitraryTerm
|
2015-12-17 21:08:47 +03:00
|
|
|
|
|
|
|
spec :: Spec
|
2016-01-05 18:38:51 +03:00
|
|
|
spec = parallel $ do
|
2015-12-17 21:08:47 +03:00
|
|
|
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
|
2015-12-17 21:08:47 +03:00
|
|
|
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
|