module AERN2.MP.Ball.Tests
(
specMPBall, tMPBall
)
where
import MixedTypesNumPrelude
import Test.Hspec
import Test.QuickCheck
import AERN2.MP.Precision
import AERN2.MP.UseMPFR.Ball.Type
import AERN2.MP.UseMPFR.Ball.Comparisons ()
import AERN2.MP.UseMPFR.Ball.Field ()
import AERN2.MP.UseMPFR.Ball.Elementary ()
instance Arbitrary MPBall where
arbitrary =
do
c <- finiteMPFloat
e <- smallEB
return (reducePrecionIfInaccurate $ MPBall c e)
where
smallEB =
do
e <- arbitrary
if (mpBall e) !<! 10
then return e
else smallEB
finiteMPFloat =
do
x <- arbitrary
if isFinite x
then return x
else finiteMPFloat
tMPBall :: T MPBall
tMPBall = T "MPBall"
specMPBall :: Spec
specMPBall =
describe ("MPBall") $ do
specCanSetPrecision tMPBall (printArgsIfFails2 "`contains`" contains)
specCanReduceSizeUsingAccuracyGuide tMPBall
specConversion tInteger tMPBall mpBall (fst . integerBounds)
describe "order" $ do
specHasEqNotMixed tMPBall
specHasEq tInt tMPBall tRational
specCanTestZero tMPBall
specHasOrderNotMixed tMPBall
specHasOrder tInt tMPBall tRational
describe "min/max/abs" $ do
specCanNegNum tMPBall
specCanAbs tMPBall
specCanMinMaxNotMixed tMPBall
specCanMinMax tMPBall tInteger tMPBall
describe "ring" $ do
specCanAddNotMixed tMPBall
specCanAddSameType tMPBall
specCanAdd tInt tMPBall tRational
specCanAdd tInteger tMPBall tInt
specCanSubNotMixed tMPBall
specCanSub tMPBall tInteger
specCanSub tInteger tMPBall
specCanSub tMPBall tInt
specCanSub tInt tMPBall
specCanMulNotMixed tMPBall
specCanMulSameType tMPBall
specCanMul tInt tMPBall tRational
describe "field" $ do
specCanDivNotMixed tMPBall
specCanDiv tInteger tMPBall
specCanDiv tMPBall tInt
specCanDiv tMPBall tRational
describe "elementary" $ do
specCanExpReal tMPBall
specCanLogReal tMPBall
specCanSqrtReal tMPBall
specCanSinCosReal tMPBall