mirror of
https://github.com/github/semantic.git
synced 2024-11-28 01:47:01 +03:00
Test that we generate terms of the specified size.
This commit is contained in:
parent
13277ddc51
commit
6a7ec24640
@ -3,6 +3,7 @@ module TermSpec where
|
||||
import ArbitraryTerm
|
||||
import Category
|
||||
import Data.String
|
||||
import Data.Functor.Foldable
|
||||
import Data.Text.Arbitrary ()
|
||||
import Diff
|
||||
import Interpreter
|
||||
@ -10,6 +11,7 @@ import Prologue
|
||||
import Term.Arbitrary
|
||||
import Test.Hspec
|
||||
import Test.Hspec.QuickCheck
|
||||
import Test.QuickCheck
|
||||
|
||||
spec :: Spec
|
||||
spec = parallel $ do
|
||||
@ -17,6 +19,9 @@ spec = parallel $ do
|
||||
prop "equality is reflexive" $
|
||||
\ a -> toTerm a == toTerm (a :: ArbitraryTerm String ())
|
||||
|
||||
prop "generates terms of a specific size" $ forAll ((arbitrary >>= \ n -> (,) n <$> termOfSize n) `suchThat` ((> 0) . fst)) $
|
||||
\ (n, term) -> cata (succ . sum) (toTerm (term :: ArbitraryTerm String ())) `shouldBe` n
|
||||
|
||||
describe "Diff" $ do
|
||||
prop "equality is reflexive" $
|
||||
\ a b -> let diff = interpret comparable diffCost (toTerm a) (toTerm (b :: ArbitraryTerm String CategorySet)) in
|
||||
|
Loading…
Reference in New Issue
Block a user