Skip to content

Commit 4659e9f

Browse files
committed
Test that the signed distance to the plane is 0.
1 parent 6b1aaf9 commit 4659e9f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/Geometry/Plane/Test.hs

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,27 @@ module Geometry.Plane.Test
33
( tests
44
) where
55

6-
import Hedgehog
6+
import Geometry.Plane
7+
import Hedgehog
8+
import qualified Hedgehog.Gen as Gen
9+
import qualified Hedgehog.Range as Range
10+
import Linear.V2
11+
12+
prop_signedDistance_identity = property $ do
13+
v <- forAll $ v2 coord
14+
n <- forAll (v2 (nonZero coord))
15+
signedDistance v n v === 0
16+
17+
18+
coord :: MonadGen m => m Rational
19+
coord = Gen.realFrac_ (Range.linearFrac (-100) 100)
20+
21+
nonZero :: (MonadGen m, Num a, Eq a) => m a -> m a
22+
nonZero = Gen.filterT (/= 0)
23+
24+
v2 :: MonadGen m => m a -> m (V2 a)
25+
v2 g = V2 <$> g <*> g
26+
727

828
tests :: IO Bool
929
tests = checkParallel $$(discover)

0 commit comments

Comments
 (0)