(round): Add some fraction cases.
authorKevin Ryde <user42@zip.com.au>
Sat, 2 Apr 2005 00:32:03 +0000 (00:32 +0000)
committerKevin Ryde <user42@zip.com.au>
Sat, 2 Apr 2005 00:32:03 +0000 (00:32 +0000)
test-suite/tests/numbers.test

index c4bb044..880ffdd 100644 (file)
        (and (= x    (round x))
             (exact? (round x))))))
 
+  (with-test-prefix "frac"
+    (define (=exact x y)
+      (and (= x y)
+          (exact? y)))
+
+    (pass-if (=exact -2 (round -7/3)))
+    (pass-if (=exact -2 (round -5/3)))
+    (pass-if (=exact -1 (round -4/3)))
+    (pass-if (=exact -1 (round -2/3)))
+    (pass-if (=exact  0 (round -1/3)))
+    (pass-if (=exact  0 (round  1/3)))
+    (pass-if (=exact  1 (round  2/3)))
+    (pass-if (=exact  1 (round  4/3)))
+    (pass-if (=exact  2 (round  5/3)))
+    (pass-if (=exact  2 (round  7/3)))
+
+    (pass-if (=exact -3 (round -17/6)))
+    (pass-if (=exact -3 (round -16/6)))
+    (pass-if (=exact -2 (round -15/6)))
+    (pass-if (=exact -2 (round -14/6)))
+    (pass-if (=exact -2 (round -13/6)))
+    (pass-if (=exact -2 (round -11/6)))
+    (pass-if (=exact -2 (round -10/6)))
+    (pass-if (=exact -2 (round  -9/6)))
+    (pass-if (=exact -1 (round  -8/6)))
+    (pass-if (=exact -1 (round  -7/6)))
+    (pass-if (=exact -1 (round  -5/6)))
+    (pass-if (=exact -1 (round  -4/6)))
+    (pass-if (=exact  0 (round  -3/6)))
+    (pass-if (=exact  0 (round  -2/6)))
+    (pass-if (=exact  0 (round  -1/6)))
+    (pass-if (=exact  0 (round   1/6)))
+    (pass-if (=exact  0 (round   2/6)))
+    (pass-if (=exact  0 (round   3/6)))
+    (pass-if (=exact  1 (round   4/6)))
+    (pass-if (=exact  1 (round   5/6)))
+    (pass-if (=exact  1 (round   7/6)))
+    (pass-if (=exact  1 (round   8/6)))
+    (pass-if (=exact  2 (round   9/6)))
+    (pass-if (=exact  2 (round  10/6)))
+    (pass-if (=exact  2 (round  11/6)))
+    (pass-if (=exact  2 (round  13/6)))
+    (pass-if (=exact  2 (round  14/6)))
+    (pass-if (=exact  2 (round  15/6)))
+    (pass-if (=exact  3 (round  16/6)))
+    (pass-if (=exact  3 (round  17/6))))
+
   (with-test-prefix "real"
     (pass-if "0.0"
       (and (= 0.0    (round 0.0))