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
|
2016-02-04 21:59:33 +03:00
|
|
|
import Category
|
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-04-12 11:54:32 +03:00
|
|
|
\ a b -> let diff = interpret comparable 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-04-12 11:54:32 +03:00
|
|
|
diffCost (interpret comparable diffCost term term) == 0
|