From: Michael Orlitzky Date: Fri, 10 Jun 2011 18:27:44 +0000 (-0400) Subject: Create a limit on the min/max function values that will be generated. X-Git-Tag: 0.0.1~283 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=9b9acc3fbb79d737a39a9f4def70621440933095;p=spline3.git Create a limit on the min/max function values that will be generated. --- diff --git a/src/Tests/FunctionValues.hs b/src/Tests/FunctionValues.hs index 3dc38a4..3694f03 100644 --- a/src/Tests/FunctionValues.hs +++ b/src/Tests/FunctionValues.hs @@ -8,35 +8,48 @@ import Assertions import Examples import FunctionValues +-- | We perform addition with the function values contained in a +-- FunctionValues object. If we choose random doubles near the machine +-- min/max, we risk overflowing or underflowing the 'Double'. This +-- places a reasonably safe limit on the maximum size of our generated +-- 'Double' members. +max_double :: Double +max_double = 10000.0 + +-- | See 'max_double'. +min_double :: Double +min_double = (-1) * max_double + + instance Arbitrary FunctionValues where arbitrary = do - front' <- arbitrary :: Gen Double - back' <- arbitrary :: Gen Double - left' <- arbitrary :: Gen Double - right' <- arbitrary :: Gen Double - top' <- arbitrary :: Gen Double - down' <- arbitrary :: Gen Double - front_left' <- arbitrary :: Gen Double - front_right' <- arbitrary :: Gen Double - front_top' <- arbitrary :: Gen Double - front_down' <- arbitrary :: Gen Double - back_left' <- arbitrary :: Gen Double - back_right' <- arbitrary :: Gen Double - back_top' <- arbitrary :: Gen Double - back_down' <- arbitrary :: Gen Double - left_top' <- arbitrary :: Gen Double - left_down' <- arbitrary :: Gen Double - right_top' <- arbitrary :: Gen Double - right_down' <- arbitrary :: Gen Double - front_left_top' <- arbitrary :: Gen Double - front_left_down' <- arbitrary :: Gen Double - front_right_top' <- arbitrary :: Gen Double - front_right_down' <- arbitrary :: Gen Double - back_left_top' <- arbitrary :: Gen Double - back_left_down' <- arbitrary :: Gen Double - back_right_top' <- arbitrary :: Gen Double - back_right_down' <- arbitrary :: Gen Double - interior' <- arbitrary :: Gen Double + front' <- choose (min_double, max_double) + back' <- choose (min_double, max_double) + left' <- choose (min_double, max_double) + right' <- choose (min_double, max_double) + top' <- choose (min_double, max_double) + down' <- choose (min_double, max_double) + front_left' <- choose (min_double, max_double) + front_right' <- choose (min_double, max_double) + front_top' <- choose (min_double, max_double) + front_down' <- choose (min_double, max_double) + back_left' <- choose (min_double, max_double) + back_right' <- choose (min_double, max_double) + back_top' <- choose (min_double, max_double) + back_down' <- choose (min_double, max_double) + left_top' <- choose (min_double, max_double) + left_down' <- choose (min_double, max_double) + right_top' <- choose (min_double, max_double) + right_down' <- choose (min_double, max_double) + front_left_top' <- choose (min_double, max_double) + front_left_down' <- choose (min_double, max_double) + front_right_top' <- choose (min_double, max_double) + front_right_down' <- choose (min_double, max_double) + back_left_top' <- choose (min_double, max_double) + back_left_down' <- choose (min_double, max_double) + back_right_top' <- choose (min_double, max_double) + back_right_down' <- choose (min_double, max_double) + interior' <- choose (min_double, max_double) return empty_values { front = front', back = back',