-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tiny QuickCheck test library with minimal dependencies -- -- A tiny (1 module, <500 lines) property-based (and unit) testing -- library with minimal dependencies. -- -- Don't add a bunch of transitive dependencies just to test your code! -- -- Instead of reinventing the wheel (https://xkcd.com/927), we use -- a RSpec/HSpec-like API and run tests with QuickCheck. -- --
-- import Test.Microspec -- -- main :: IO () -- main = microspec $ do -- describe "replicate" $ do -- it "doubles with 2" $ -- replicate 2 'x' == "xx" -- it "creates a list of the right size" $ -- \(Positive n) -> length (replicate n 'x') == n -- -- describe "reverse" $ do -- it "reverse . reverse == id" $ \l -> -- reverse (reverse l) == (l :: [Int]) -- -- describe "tail" $ -- it "length is -1" $ \(NonEmpty l) -> -- length (tail l :: [Int]) == length l - 1 -- -- describe "solve the halting problem" $ -- pending --@package microspec @version 0.1.0.0 -- | Tests can be structured as nested it / describe -- statements -- -- E.g. -- --
-- microspec $ do -- describe "plus" $ do -- it "adds positive numbers" $ do -- it "does 1 + 1" $ -- 1 + 1 == 2 -- it "does 2 + 2" $ -- 2 + 2 == 4 -- it "is commutative" $ -- \x y -> x + y == y + (x :: Int) ---- -- ...which will return, nicely in green instead of bold: -- --
-- plus -- adds positive numbers -- does 1 + 1 -- does 2 + 2 -- is commutative -- --module Test.Microspec -- | Run your spec. Put this at the top level, e.g.: -- --
-- main = microspec $ do -- describe "plus 1" $ -- 3 + 1 == 4 --microspec :: Microspec () -> IO () -- | microspec with MArgs microspecWith :: MArgs -> Microspec () -> IO () -- | Describe a test, e.g.: -- --
-- describe "reverse 'foo' is 'oof'" $ -- reverse "foo" === "oof" --describe :: MTestable t => String -> t -> Microspec () -- | An alias for describe. Usually used inside a describe -- block: -- --
-- describe "replicate" $ do -- it "doubles with 2" $ -- replicate 2 'x' === "xx" -- it "creates a list of the right size" $ -- \(Positive n) -> length (replicate n 'x') == n --it :: MTestable t => String -> t -> Microspec () -- | Describe a test as unwritten, e.g.: -- --
-- describe "meaning of life" $ pending --pending :: Pending -- | Make a test case from a QuickCheck function. Alias for -- property. -- -- Note that you don't need to use this to create a test, e.g.: -- --
-- describe "reverse preserves length" $ -- \l -> length (reverse l) == length l --prop :: Testable prop => prop -> Property -- | A series of tests, to run with microspec data Microspec a -- | Something which can be tested -- -- Note both Bools and Properties can be tested, but only Properties show -- the values that weren't equal -- -- For both unit tests and property tests, if you want to see the outputs -- of failed tests use ===. If you just want to test for equality, -- use ==. -- -- For example, the outputs of running: -- --
-- microspec $ do -- describe "baddies" $ do -- it "isn't 1 ==" $ 0 == (1 :: Int) -- it "isn't 1 ===" $ 0 === (1 :: Int) -- it "isn't always 1 ==" $ x -> x == (1 :: Int) -- it "isn't always 1 ===" $ x -> x === (1 :: Int) -- ---- -- are: -- --
-- isn't 1 == - *** Failed! Falsifiable (after 1 test) -- isn't 1 === - *** Failed! Falsifiable (after 1 test): | 0 /= 1 -- isn't always 1 == - *** Failed! Falsifiable (after 1 test): | 0 -- isn't always 1 === - *** Failed! Falsifiable (after 1 test): | 0 | 0 /= 1 -- --class MTestable t -- | Describe a test, e.g.: -- --
-- describe "reverse 'foo' is 'oof'" $ -- reverse "foo" === "oof" --describe :: MTestable t => String -> t -> Microspec () -- | Tweak how tests are run, with microspecWith. data MArgs MArgs :: Maybe Double -> Args -> MArgs -- | Number of seconds before each test times out. If you want to do this -- on a per-test basis, try within [_mArgs_timeoutSecs] :: MArgs -> Maybe Double -- | Arguments to use with QuickCheck tests [_mArgs_qcArgs] :: MArgs -> Args -- | Default arguments. Calling "microspec" is the same as calling -- "microspecWith defaultMArgs". defaultMArgs :: MArgs -- | Hspec compatibility. Equivalent to using === shouldBe :: (Eq x, Show x) => x -> x -> Property instance GHC.Read.Read Test.Microspec.MArgs instance GHC.Show.Show Test.Microspec.MArgs instance Test.Microspec.MTestable Test.QuickCheck.Property.Property instance Test.Microspec.MTestable GHC.Types.Bool instance Test.Microspec.MTestable Test.Microspec.TestTree instance Test.Microspec.MTestable Test.Microspec.Pending instance Test.Microspec.MTestable (Test.Microspec.Microspec ()) instance (Test.QuickCheck.Arbitrary.Arbitrary a, GHC.Show.Show a, Test.QuickCheck.Property.Testable prop) => Test.Microspec.MTestable (a -> prop) instance GHC.Show.Show Test.Microspec.TestTree instance GHC.Base.Functor Test.Microspec.Microspec instance GHC.Base.Applicative Test.Microspec.Microspec instance GHC.Base.Monad Test.Microspec.Microspec