File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE GeneralizedNewtypeDeriving #-}
1
2
{-# LANGUAGE TemplateHaskell #-}
2
3
{-# LANGUAGE TypeApplications #-}
3
4
module Geometry.Plane.Test
@@ -19,7 +20,7 @@ prop_signedDistance_identity = property $ do
19
20
prop_signedDistance_unit = property $ do
20
21
v <- forAll $ v2 coord
21
22
n <- signorm <$> forAll (v2 (nonZero coord))
22
- roundToPlaces 5 (signedDistance v n (v + n)) === 1
23
+ Near (signedDistance v n (v + n)) === 1
23
24
24
25
25
26
coord :: MonadGen m => m Double
@@ -40,3 +41,10 @@ roundToPlaces :: RealFrac a => Int -> a -> a
40
41
roundToPlaces p x = fromInteger (round (x * p')) / p'
41
42
where
42
43
p' = 10 ^ p
44
+
45
+
46
+ newtype Near a = Near a
47
+ deriving (Num , Show )
48
+
49
+ instance RealFrac a => Eq (Near a ) where
50
+ Near a == Near b = roundToPlaces 5 a == roundToPlaces 5 b
You can’t perform that action at this time.
0 commit comments