1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
-- |
module Diagrams.Test.Angle where
import Test.Tasty
import Test.Tasty.QuickCheck
import Diagrams.Prelude
import Instances
tests :: TestTree
tests = testGroup "Angle" [
testProperty "2π radians per turn" $
\θ -> θ^.rad =~ θ^.turn*2*(pi :: Double)
, testProperty "360 degrees per turn" $
\θ -> θ^.deg =~ θ^.turn*(360 :: Double)
, testProperty "Angle vector addition is commutative" $
\θ φ -> (θ :: Angle Double) ^+^ φ =~ φ ^+^ θ
, testProperty "Angle subtraction is the inverse of addition" $
\θ φ -> (θ :: Angle Double) ^+^ φ ^-^ φ =~ θ
, testProperty "Angle vector negation squared is identity" $
\θ -> negated (negated (θ :: Angle Double)) =~ θ
, testProperty "A negated angle is the additive inverse of the original" $
\θ -> (θ :: Angle Double) ^+^ (negated θ) =~ 0@@turn
, testProperty "A negated angle is the additive inverse of the original" $
\θ -> (θ :: Angle Double) ^+^ (negated θ) =~ 0@@turn
]
|