1 module Tests.FunctionValues
11 -- | We perform addition with the function values contained in a
12 -- FunctionValues object. If we choose random doubles near the machine
13 -- min/max, we risk overflowing or underflowing the 'Double'. This
14 -- places a reasonably safe limit on the maximum size of our generated
19 -- | See 'max_double'.
21 min_double = (-1) * max_double
24 instance Arbitrary FunctionValues where
26 front' <- choose (min_double, max_double)
27 back' <- choose (min_double, max_double)
28 left' <- choose (min_double, max_double)
29 right' <- choose (min_double, max_double)
30 top' <- choose (min_double, max_double)
31 down' <- choose (min_double, max_double)
32 front_left' <- choose (min_double, max_double)
33 front_right' <- choose (min_double, max_double)
34 front_top' <- choose (min_double, max_double)
35 front_down' <- choose (min_double, max_double)
36 back_left' <- choose (min_double, max_double)
37 back_right' <- choose (min_double, max_double)
38 back_top' <- choose (min_double, max_double)
39 back_down' <- choose (min_double, max_double)
40 left_top' <- choose (min_double, max_double)
41 left_down' <- choose (min_double, max_double)
42 right_top' <- choose (min_double, max_double)
43 right_down' <- choose (min_double, max_double)
44 front_left_top' <- choose (min_double, max_double)
45 front_left_down' <- choose (min_double, max_double)
46 front_right_top' <- choose (min_double, max_double)
47 front_right_down' <- choose (min_double, max_double)
48 back_left_top' <- choose (min_double, max_double)
49 back_left_down' <- choose (min_double, max_double)
50 back_right_top' <- choose (min_double, max_double)
51 back_right_down' <- choose (min_double, max_double)
52 interior' <- choose (min_double, max_double)
54 return empty_values { front = front',
60 front_left = front_left',
61 front_right = front_right',
62 front_top = front_top',
63 front_down = front_down',
64 back_left = back_left',
65 back_right = back_right',
67 back_down = back_down',
69 left_down = left_down',
70 right_top = right_top',
71 right_down = right_down',
72 front_left_top = front_left_top',
73 front_left_down = front_left_down',
74 front_right_top = front_right_top',
75 front_right_down = front_right_down',
76 back_left_top = back_left_top',
77 back_left_down = back_left_down',
78 back_right_top = back_right_top',
79 back_right_down = back_right_down',
80 interior = interior' }
85 test_directions :: Test
87 TestCase $ assertTrue "all direction functions work" (and equalities)
89 fvs = make_values trilinear 1 1 1
90 equalities = [ interior fvs == 4,
102 back_right fvs == 11,
109 front_left_down fvs == 1,
110 front_left_top fvs == 1,
111 front_right_down fvs == 1,
112 front_right_top fvs == 1,
113 back_left_down fvs == 3,
114 back_left_top fvs == 3,
115 back_right_down fvs == 7,
116 back_right_top fvs == 15]
118 function_values_tests :: [Test]
119 function_values_tests = [test_directions]