@@ -10,7 +10,7 @@ import Data.Number.Approximate (Fraction(..), Tolerance(..), eqRelative,
1010 eqAbsolute , (≅), (≇))
1111
1212import Effect (Effect )
13-
13+ import Effect.Console ( log )
1414import Test.Assert (assertTrue' , assertFalse' , assertEqual )
1515
1616
@@ -30,8 +30,8 @@ main :: Effect Unit
3030main = do
3131
3232
33- -- suite "Data.Number.fromString" do
34- -- test "valid number string" do
33+ log " Data.Number.fromString"
34+ log " \t valid number string"
3535 assertTrue' " integer strings are coerced" $
3636 fromMaybe false $ map (_ == 123.0 ) $ fromString " 123"
3737
@@ -44,31 +44,31 @@ main = do
4444 assertTrue' " decimals exponents are coerced" $
4545 fromMaybe false $ map (_ == 1.2e4 ) $ fromString " 1.2e4"
4646
47- -- test "invalid number string" do
47+ log " \t invalid number string"
4848 assertTrue' " invalid strings are not coerced" $
4949 Nothing == fromString " bad string"
5050
51- -- test "too large numbers" do
51+ log " \t too large numbers"
5252 assertTrue' " too large numbers are not coerced" $
5353 Nothing == fromString " 1e1000"
5454
55- -- suite "Data.Number.isNaN" do
56- -- test "Check for NaN" do
55+ log " Data.Number.isNaN"
56+ log " \t Check for NaN"
5757 assertTrue' " NaN is not a number" $ isNaN nan
5858 assertFalse' " infinity is a number" $ isNaN infinity
5959 assertFalse' " 1.0 is a number" $ isNaN 1.0
6060
61- -- suite "Data.Number.isFinite" do
62- -- test "Check for infinity" do
61+ log " Data.Number.isFinite"
62+ log " \t Check for infinity"
6363 assertTrue' " 1.0e100 is a finite number" $ isFinite 1.0e100
6464 assertFalse' " detect positive infinity" $ isFinite infinity
6565 assertFalse' " detect negative infinity" $ isFinite (-infinity)
6666 assertFalse' " detect NaN" $ isFinite nan
6767
6868 let pi = 3.14159
69- -- suite "Data.Format.toStringWith" do
69+ log " Data.Format.toStringWith"
7070
71- -- test "precision" do
71+ log " \t precision "
7272 assertEqual
7373 { expected: " 3.14"
7474 , actual: toStringWith (precision 3 ) pi
@@ -94,7 +94,7 @@ main = do
9494 , actual: toStringWith (precision 2 ) 1234.5
9595 }
9696
97- -- test "fixed" do
97+ log " \t fixed "
9898 assertEqual
9999 { expected: " 3.14"
100100 , actual: toStringWith (fixed 2 ) pi
@@ -116,7 +116,7 @@ main = do
116116 , actual: toStringWith (fixed 1 ) 1234.5
117117 }
118118
119- -- test "exponential" do
119+ log " \t exponential "
120120 assertEqual
121121 { expected: " 3e+0"
122122 , actual: toStringWith (exponential 0 ) pi
@@ -134,9 +134,9 @@ main = do
134134 , actual: toStringWith (exponential 1 ) 1234.5
135135 }
136136
137- -- suite "Data.Format.toString" do
137+ log " Data.Format.toString"
138138
139- -- test "toString" do
139+ log " \t toString "
140140 assertEqual
141141 { expected: " 3.14159"
142142 , actual: toString pi
@@ -147,8 +147,8 @@ main = do
147147 , actual: toString 10.0
148148 }
149149
150- -- suite "Data.Number.Approximate.eqRelative" do
151- -- test "eqRelative" do
150+ log " Data.Number.Approximate.eqRelative"
151+ log " \t eqRelative "
152152 assertTrue' " should return true for differences smaller 10%" $
153153 10.0 ~= 10.9
154154
@@ -161,7 +161,7 @@ main = do
161161 assertFalse' " should return false for differences larger than 10%" $
162162 10.0 ~= 9.01
163163
164- -- test "eqRelative (large numbers)" do
164+ log " \t eqRelative (large numbers)"
165165 assertTrue' " should return true for differences smaller 10%" $
166166 100000000000.0 ~= 109000000000.0
167167
@@ -174,7 +174,7 @@ main = do
174174 assertFalse' " should return false for differences larger than 10%" $
175175 100000000000.0 ~= 90000000000.0
176176
177- -- test "eqRelative (small numbers)" do
177+ log " \t eqRelative (small numbers)"
178178 assertTrue' " should return true for differences smaller 10%" $
179179 0.000000000001 ~= 0.00000000000109
180180
@@ -188,7 +188,7 @@ main = do
188188 assertFalse' " should return false for differences larger than 10%" $
189189 0.000000000001 ~= 0.0000000000009
190190
191- -- test "eqRelative (negative numbers)" do
191+ log " \t eqRelative (negative numbers)"
192192 assertTrue' " should return true for differences smaller 10%" $
193193 -10.0 ~= -10.9
194194
@@ -201,7 +201,7 @@ main = do
201201 assertFalse' " should return false for differences larger than 10%" $
202202 -10.0 ~= -9.01
203203
204- -- test "eqRelative (close or equal to 0.0)" do
204+ log " \t eqRelative (close or equal to 0.0)"
205205 assertTrue' " should compare against the fraction if left argument is zero" $
206206 0.0 ~= 0.0001
207207
@@ -217,29 +217,29 @@ main = do
217217 assertFalse' " should fail if other argument is not exactly zero" $
218218 1.0e-100 ~= 0.1
219219
220- -- test "eqRelative (fraction = 0.0)" do
220+ log " \t eqRelative (fraction = 0.0)"
221221 assertTrue' " should succeed if numbers are exactly equal" $
222222 eqRelative (Fraction 0.0 ) 3.14 3.14
223223
224224 assertFalse' " should fail if numbers are not exactly equal" $
225225 eqRelative (Fraction 0.0 ) 3.14 3.14000000000001
226226
227- -- test "eqRelative (fraction > 1.0)" do
227+ log " \t eqRelative (fraction > 1.0)"
228228 assertTrue' " should work for 'fractions' larger than one" $
229229 eqRelative (Fraction 3.0 ) 10.0 29.5
230230
231231
232- -- suite "Data.Number.Approximate.eqApproximate" do
233- -- test "0 .1 + 0.2 ≅ 0.3" do
232+ log " Data.Number.Approximate.eqApproximate"
233+ log " \t 0 .1 + 0.2 ≅ 0.3"
234234 assertTrue' " 0.1 + 0.2 should be approximately equal to 0.3" $
235235 0.1 + 0.2 ≅ 0.3
236236
237237 assertTrue' " 0.1 + 0.200001 should not be approximately equal to 0.3" $
238238 0.1 + 0.200001 ≇ 0.3
239239
240240
241- -- suite "Data.Number.Approximate.eqAbsolute" do
242- -- test "eqAbsolute" do
241+ log " Data.Number.Approximate.eqAbsolute"
242+ log " \t eqAbsolute "
243243 assertTrue' " should succeed for differences smaller than the tolerance" $
244244 10.0 =~= 10.09
245245
@@ -252,6 +252,6 @@ main = do
252252 assertFalse' " should fail for differences larger than the tolerance" $
253253 9.89 =~= 10.0
254254
255- -- test "eqAbsolute (compare against 0)" do
255+ log " \t eqAbsolute (compare against 0)"
256256 assertTrue' " should succeed for numbers smaller than the tolerance" $
257257 0.0 ~= -0.09
0 commit comments