| 1 |
;; |
| 2 |
;; Test spigot module |
| 3 |
;; |
| 4 |
|
| 5 |
(use gauche.test) |
| 6 |
|
| 7 |
(test-start "spigot") |
| 8 |
(use math.spigot) |
| 9 |
(test-module 'math.spigot) ;; This checks the exported symbols are indeed bound. |
| 10 |
|
| 11 |
;; Normal operation test |
| 12 |
(test* "spigot-calculate-pi (10)" |
| 13 |
'#(3 1 4 1 5 9 2 6 5 3) |
| 14 |
(spigot-calculate-pi 10)) |
| 15 |
|
| 16 |
(test* "spigot-calculate-e (15)" |
| 17 |
'#(2 7 1 8 2 8 1 8 2 8 4 5 9 0 4) |
| 18 |
(spigot-calculate-e 15)) |
| 19 |
|
| 20 |
(test* "spigot-calculate-pi (1)" |
| 21 |
'#(3) |
| 22 |
(spigot-calculate-pi 1)) |
| 23 |
|
| 24 |
(test* "spigot-calculate-e (1)" |
| 25 |
'#(2) |
| 26 |
(spigot-calculate-e 1)) |
| 27 |
|
| 28 |
;; See if they reports error for invalid arguments. |
| 29 |
(test* "spigot-calculate-pi (0)" |
| 30 |
*test-error* |
| 31 |
(spigot-calculate-pi 0)) |
| 32 |
|
| 33 |
(test* "spigot-calculate-e (0)" |
| 34 |
*test-error* |
| 35 |
(spigot-calculate-e 0)) |
| 36 |
|
| 37 |
(test* "spigot-calculate-pi (-1)" |
| 38 |
*test-error* |
| 39 |
(spigot-calculate-pi -1)) |
| 40 |
|
| 41 |
(test* "spigot-calculate-e (-1)" |
| 42 |
*test-error* |
| 43 |
(spigot-calculate-e -1)) |
| 44 |
|
| 45 |
(test-end) |