Skip to content

Instantly share code, notes, and snippets.

@shapr
Created April 7, 2022 17:39
Show Gist options
  • Save shapr/1e205f73d0d6e3d9c4617ce3e864f5f5 to your computer and use it in GitHub Desktop.
Save shapr/1e205f73d0d6e3d9c4617ce3e864f5f5 to your computer and use it in GitHub Desktop.
fails as expected
#!/usr/bin/env cabal
{- cabal:
build-depends: base
, QuickCheck
-}
module Main where
import Test.QuickCheck
-- associative: ((a `op` b) `op` c) == (a `op` (b `op` c))
prop_associative_int :: Int -> Int -> Int -> Bool
prop_associative_int a b c = ((a * b) * c) == (a * (b * c))
prop_associative_float :: Float -> Float -> Float -> Bool
prop_associative_float x y z = ((x * y) * z) == (x * (y * z))
-- reflexive: is something equal to itself?
prop_reflexive :: Float -> Bool
prop_reflexive f = f == f
prop_reflexive' :: Float -> Bool
prop_reflexive' f = (f / 0) == (f / 0)
main = do
quickCheck $ (withMaxSuccess 10000) prop_reflexive'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment