Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
- type HasEq t1 t2 = (HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, EqCompareType t1 t2 ~ EqCompareType t2 t1)
- class IsBool (EqCompareType a b) => HasEqAsymmetric a b where
- type EqCompareType a b
- (==) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b
- (/=) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b
- type HasEqCertainly t1 t2 = (HasEq t1 t2, CanTestCertainly (EqCompareType t1 t2))
- type HasEqCertainlyAsymmetric t1 t2 = (HasEqAsymmetric t1 t2, CanTestCertainly (EqCompareType t1 t2))
- notCertainlyDifferentFrom :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- certainlyEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- certainlyNotEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- (?==?) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- (!==!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- (!/=!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- specHasEq :: (HasEqX t1 t1, HasEqX t1 t2, HasEqX t2 t1, HasEqX t1 t3, HasEqX t2 t3, CanAndOrX (EqCompareType t1 t2) (EqCompareType t2 t3)) => T t1 -> T t2 -> T t3 -> Spec
- specHasEqNotMixed :: (HasEqX t t, CanAndOrX (EqCompareType t t) (EqCompareType t t)) => T t -> Spec
- type HasEqX t1 t2 = (HasEqCertainly t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2)
- specConversion :: (Arbitrary t1, Show t1, HasEqCertainly t1 t1) => T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec
- class CanTestFinite t where
- class CanTestInteger t where
- class CanTestZero t where
- specCanTestZero :: (CanTestZero t, ConvertibleExactly Integer t) => T t -> Spec
- class CanPickNonZero t where
- specCanPickNonZero :: (CanPickNonZero t, CanTestZero t, ConvertibleExactly Integer t, Show t, Arbitrary t) => T t -> Spec
Equality checks
type HasEq t1 t2 = (HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, EqCompareType t1 t2 ~ EqCompareType t2 t1) Source #
class IsBool (EqCompareType a b) => HasEqAsymmetric a b where Source #
type EqCompareType a b Source #
equalTo :: a -> b -> EqCompareType a b Source #
equalTo :: (EqCompareType a b ~ Bool, a ~ b, Eq a) => a -> b -> Bool Source #
notEqualTo :: a -> b -> EqCompareType a b Source #
notEqualTo :: CanNegSameType (EqCompareType a b) => a -> b -> EqCompareType a b Source #
(==) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b infix 4 Source #
(/=) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b infix 4 Source #
type HasEqCertainly t1 t2 = (HasEq t1 t2, CanTestCertainly (EqCompareType t1 t2)) Source #
type HasEqCertainlyAsymmetric t1 t2 = (HasEqAsymmetric t1 t2, CanTestCertainly (EqCompareType t1 t2)) Source #
notCertainlyDifferentFrom :: HasEqCertainlyAsymmetric a b => a -> b -> Bool Source #
certainlyEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool Source #
certainlyNotEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool Source #
(?==?) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool infix 4 Source #
(!==!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool infix 4 Source #
(!/=!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool infix 4 Source #
Tests
specHasEq :: (HasEqX t1 t1, HasEqX t1 t2, HasEqX t2 t1, HasEqX t1 t3, HasEqX t2 t3, CanAndOrX (EqCompareType t1 t2) (EqCompareType t2 t3)) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of HasEq should satisfy.
specHasEqNotMixed :: (HasEqX t t, CanAndOrX (EqCompareType t t) (EqCompareType t t)) => T t -> Spec Source #
HSpec properties that each implementation of HasEq should satisfy.
type HasEqX t1 t2 = (HasEqCertainly t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2) Source #
Compound type constraint useful for test definition.
specConversion :: (Arbitrary t1, Show t1, HasEqCertainly t1 t1) => T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec Source #
HSpec property of there-and-back conversion.
Specific comparisons
class CanTestFinite t where Source #
class CanTestInteger t where Source #
certainlyNotInteger :: t -> Bool Source #
certainlyInteger :: t -> Bool Source #
certainlyIntegerGetIt :: t -> Maybe Integer Source #
class CanTestZero t where Source #
isCertainlyZero :: t -> Bool Source #
isNonZero :: t -> Bool Source #
isCertainlyZero :: HasEqCertainly t Integer => t -> Bool Source #
specCanTestZero :: (CanTestZero t, ConvertibleExactly Integer t) => T t -> Spec Source #
HSpec properties that each implementation of CanTestZero should satisfy.
class CanPickNonZero t where Source #
pickNonZero :: [(t, s)] -> (t, s) Source #
Given a list [(a1,b1),(a2,b2),...]
and assuming that
at least one of a1,a2,...
is non-zero, pick one of them
and return the corresponding pair (ai,bi)
.
If none of a1,a2,...
is zero, either throws an exception
or loops forever.
The default implementation is based on a CanTestZero
instance
and is not parallel.
pickNonZero :: (CanTestZero t, Show t) => [(t, s)] -> (t, s) Source #
Given a list [(a1,b1),(a2,b2),...]
and assuming that
at least one of a1,a2,...
is non-zero, pick one of them
and return the corresponding pair (ai,bi)
.
If none of a1,a2,...
is zero, either throws an exception
or loops forever.
The default implementation is based on a CanTestZero
instance
and is not parallel.
specCanPickNonZero :: (CanPickNonZero t, CanTestZero t, ConvertibleExactly Integer t, Show t, Arbitrary t) => T t -> Spec Source #
HSpec properties that each implementation of CanPickNonZero should satisfy.