~ chicken-core (master) /tests/numbers-string-conversion-tests.scm
Trap1;;;
2;;; Numerical syntax "torture test"
3;;;
4;;; This tries to test a lot of edge cases in Scheme's numerical syntax.
5;;;
6;;; Output is written so that if you run it through "grep ERROR" it will
7;;; output nothing (and exit status will be nonzero) if there are no errors.
8;;; If you run it through "tail -n 1" you will just get the total error summary.
9;;;
10;;; This code assumes that string->number accepts numbers with embedded radix
11;;; specifiers (R5RS mentions that it's allowed to return #f in those cases).
12;;; It also doesn't try to support Schemes which support *only* integers or
13;;; *only* flonums (which is also allowed by R5RS).
14;;;
15
16;;;
17;; The prelude below is messy but required to get everything working
18;; with some of the major Schemes.
19;;
20;; Also note that to test with Gambit, it appears you first need to type in
21;; (load "~~/lib/syntax-case") and then load this file, or use gsi's -:s switch
22;;;
23
24(import (chicken format)) ; Chicken w/ numbers
25;(use-syntax (ice-9 syncase)) ; Guile
26
27;; Set this to #f if the Scheme has no compnums at all, 'inexact if it only
28;; supports inexact compnums or 'exact if it supports exact compnums.
29;; (Gauche, Guile, SCM: inexact, Chicken w/o numbers: #f)
30(define compnum-type 'exact)
31
32;; Set this to #f if the Scheme has no fractional number support,
33;; 'exact if it supports rational numbers and 'inexact if it converts fractions
34;; to floating-point, inexact numbers
35(define fraction-type 'exact)
36
37;; Fix these if your Scheme doesn't allow division by zero
38(define the-nan (/ 0.0 0.0))
39(define pos-inf (/ 1.0 0.0))
40(define neg-inf (/ -1.0 0.0))
41
42; Scheme48, Racket, Gambit, SCM
43;(define (nan? x) (and (number? x) (not (= x x))))
44
45(define total-errors 0)
46
47(define (check-string-against-values! str . possible-values)
48 (let ((res (string->number str)))
49 (let lp ((values possible-values))
50 (if (null? values)
51 (begin (display "PARSE ERROR ")
52 (write (cons str possible-values))
53 (display " => ") (write res) (newline)
54 (set! total-errors (+ total-errors 1)))
55 (let ((value (car values)))
56 (if (not (or (and (not (string? value)) (equal? res value))
57 (and res (nan? res) (or (and value (nan? value))))))
58 (lp (cdr values))
59 (let ((re-str (and res (number->string res))))
60 (let lp2 ((values possible-values))
61 (if (null? values)
62 (begin (display "SERIALIZATION ERROR ")
63 (write (cons str possible-values))
64 (display " => ") (write re-str) (newline)
65 (set! total-errors (+ total-errors 1)))
66 (let ((value (car values)))
67 (if (not (or (and res (string=? re-str str))
68 (and (not res) (not value))
69 (and res (string? value) (string=? re-str value))))
70 (lp2 (cdr values))
71 (begin (display "OK ")
72 (write (cons str possible-values))
73 (newline)))))))))))))
74
75(define-syntax test-numbers
76 (syntax-rules (compnums fractions)
77 ((_ (compnums (types e1 ...) ...) rest ...)
78 (begin
79 (case compnum-type (types (test-numbers e1 ... "no-totals")) ...)
80 (test-numbers rest ...)))
81 ((_ (fractions (types e1 ...) ...) rest ...)
82 (begin
83 (case fraction-type (types (test-numbers e1 ... "no-totals")) ...)
84 (test-numbers rest ...)))
85 ((_ (str value ...) rest ...)
86 (begin
87 (check-string-against-values! str value ...)
88 (test-numbers rest ...)))
89 ((_ "no-totals") #f)
90 ((_ x rest ...)
91 (begin (newline) (display "-> ") (display x) (newline)
92 (display "-----------------------------------------------------")
93 (newline)
94 (test-numbers rest ...)))
95 ((_)
96 (if (= 0 total-errors)
97 (begin (newline)
98 (display "-----> Everything OK, no errors!")
99 (newline))
100 (begin (newline)
101 (display "-----> TOTAL ERRORS: ")
102 (display total-errors)
103 (newline)
104 (exit 1))))))
105
106(test-numbers
107 "Simple integers"
108 ("1" 1)
109 ("+1" 1 "1")
110 ("-1" (- 1))
111 ("#i1" 1.0 "1.0" "1.")
112 ("#I1" 1.0 "1.0" "1.")
113 ("#i-1" (- 1.0) "-1.0" "-1.")
114 ("123\x00;456" #f)
115 ("-#i1" #f)
116 ("+-1" #f)
117 ("" #f)
118 ("-" #f)
119 ("+" #f)
120 ("+-" #f)
121
122 "Basic decimal notation"
123 ("1.0" (exact->inexact 1) "1.")
124 ("1." 1.0 "1.0" "1.")
125 ("1.#" 1.0 1.5 "1.0" "1." "1.5")
126 (".1" 0.1 "0.1" "100.0e-3")
127 ("-.1" (- 0.1) "-0.1" "-100.0e-3")
128 ;; Some Schemes don't allow negative zero. This is okay with the standard
129 ("-.0" -0.0 "-0." "-0.0" "0.0" "0." ".0")
130 ("-0." -0.0 "-.0" "-0.0" "0.0" "0." ".0")
131 ("." #f)
132 (".1." #f)
133 ("..1" #f)
134 ("1.." #f)
135 ("#i1.0" 1.0 "1.0" "1.")
136 ("#e1.0" 1 "1")
137 ("#e-.0" 0 "0")
138 ("#e-0." 0 "0")
139 ("-#e.0" #f)
140
141 "Decimal notation with padding"
142 ("1#" 10.0 15.0 "10.0" "15.0" "10." "15.")
143 ("#e1#" 10 15 "10" "15")
144 ("#E1#" 10 15 "10" "15")
145 ("#1" #f)
146 ("#" #f)
147 ("1#2" #f)
148 ("1.#2" #f)
149 (".#" #f)
150 ("#.#" #f)
151 ("#.1" #f)
152 ("1#.2" #f)
153 ("1#." 10.0 15.0 "10.0" "15.0" "10." "15.")
154
155 "Decimal notation with suffix"
156 ("1e2" 100.0 "100.0" "100.")
157 ("1E2" 100.0 "100.0" "100.")
158 ("1s2" 100.0 "100.0" "100.")
159 ("1S2" 100.0 "100.0" "100.")
160 ("1f2" 100.0 "100.0" "100.")
161 ("1F2" 100.0 "100.0" "100.")
162 ("1d2" 100.0 "100.0" "100.")
163 ("1D2" 100.0 "100.0" "100.")
164 ("1l2" 100.0 "100.0" "100.")
165 ("1L2" 100.0 "100.0" "100.")
166 ("1e2e3" #f)
167 ("1e2s3" #f)
168 ("1e2.0" #f)
169
170 "Decimal notation with suffix and padding"
171 ("1#e2" 1000.0 1500.0 "1000.0" "1500.0" "1000." "1500." "1.0e3" "15.0e2")
172 ("1e2#" #f)
173
174 "NaN, Inf"
175 ("+nan.0" the-nan "+NaN.0")
176 ("+NAN.0" the-nan "+nan.0" "+NaN.0")
177 ("+nan.1" #f)
178 ("+nan.01" #f)
179 ("+inf.0" pos-inf "+Inf.0")
180 ("+InF.0" pos-inf "+inf.0" "+Inf.0")
181 ("-inf.0" neg-inf "-Inf.0")
182 ("-iNF.0" neg-inf "-inf.0" "-Inf.0")
183 ("+inf.01" #f)
184 ("+inf.1" #f)
185 ("-inf.01" #f)
186 ("-inf.1" #f)
187 ("+inf.0/1" #f)
188 ("1/+inf.0" #f)
189 ("+nan" #f)
190 ("+inf" #f)
191 ("-inf" #f)
192 ("nan.0" #f)
193 ("inf.0" #f)
194 ;; Thanks to John Cowan for these
195 ("#e+nan.0" #f)
196 ("#e+inf.0" #f)
197 ("#e-inf.0" #f)
198 ("#i+nan.0" the-nan "+nan.0" "+NaN.0")
199 ("#i+inf.0" pos-inf "+inf.0" "+Inf.0")
200 ("#i-inf.0" neg-inf "-inf.0" "-Inf.0")
201
202 "Fractions"
203 (fractions
204 ((exact)
205 ("1/2" (/ 1 2))
206 ("#e1/2" (/ 1 2) "1/2")
207 ("10/2" 5 "5")
208 ("-1/2" (- (/ 1 2)))
209 ("10/0" #f)
210 ("0/10" 0 "0")
211 ("#e0/10" 0 "0")
212 ("#e1#/2" 5 (/ 15 2) "5" "15/2")
213 ("#e1/2#" (/ 1 20) "1/20")
214 ("#i3/2" (/ 3.0 2.0) "1.5"))
215 ((inexact)
216 ("1/2" (/ 1 2) "0.5" ".5" "500.0e-3")
217 ("0/10" 0.0 "0.0")
218 ("10/2" 5.0 "5.0" "5.")
219 ;; Unsure what "#e1/2" is supposed to do in Scheme w/o exact fractions
220 ("#i10/2" 5.0 "5.0" "5.")
221 ("-1/2" (- (/ 1 2)) "-0.5" "-.5" "-500.0e-3")))
222 (fractions
223 ((inexact exact)
224 ("#i1/0" pos-inf "+inf.0" "+Inf.0")
225 ("#i-1/0" neg-inf "-inf.0" "-Inf.0")
226 ("#i0/0" the-nan "+nan.0" "+NaN.0")
227 ;; This _could_ be valid in some Schemes (but isn't as pretty)
228 ;("#i1/0" #f)
229 ;("#i-1/0" #f)
230 ;("#i0/0" #f)
231
232 ("1/-2" #f)
233 ("1.0/2" #f)
234 ("1/2.0" #f)
235 ("1/2e2" #f)
236 ("1/2e2" #f)
237 ("1#/2" 5.0 7.5 "5.0" "5." "7.5")
238 ("1/2#" 0.05 "0.05" ".05" "50.0e-3" "5.e-002")
239 ("1#/#" #f)
240 ("1/" #f)
241 ("1/+" #f)
242 ("+/1" #f)
243 ("/1" #f)
244 ("/" #f)))
245
246 "Basic complex numbers (rectangular notation)"
247 (compnums
248 ((exact)
249 ("1+2i" (make-rectangular 1 2))
250 ("1+2I" (make-rectangular 1 2) "1+2i")
251 ("1-2i" (make-rectangular 1 -2))
252 ("-1+2i" (make-rectangular -1 2))
253 ("-1-2i" (make-rectangular -1 -2))
254 ("+i" (make-rectangular 0 1) "+1i" "0+i" "0+1i")
255 ("0+i" (make-rectangular 0 1) "+i" "+1i" "0+1i")
256 ("0+1i" (make-rectangular 0 1) "+i" "+1i" "0+i")
257 ("-i" (make-rectangular 0 -1) "-1i" "0-i" "0-1i")
258 ("0-i" (make-rectangular 0 -1) "-i" "-1i" "0-1i")
259 ("0-1i" (make-rectangular 0 -1) "-i" "-1i" "0-i")
260 ("+2i" (make-rectangular 0 2) "0+2i")
261 ("-2i" (make-rectangular 0 -2) "-2i" "0-2i"))
262 ((inexact)
263 ("1+2i" (make-rectangular 1 2) "1.0+2.0i" "1.+2.i")
264 ("1+2I" (make-rectangular 1 2) "1.0+2.0i" "1.+2.i")
265 ("1-2i" (make-rectangular 1 -2) "1.0-2.0i" "1.-2.i")
266 ("-1+2i" (make-rectangular -1 2) "-1.0+2.0i" "-1.+2.i")
267 ("-1-2i" (make-rectangular -1 -2) "-1.0-2.0i" "-1.-2.i")
268 ("+i" (make-rectangular 0 1) "+1.i" "+1.0i" "0.+1.i" "0.0+1.0i")
269 ("0+i" (make-rectangular 0 1) "0+1i" "+1.i" "+1.0i" "0.+1.i" "0.0+1.0i")
270 ("0+1i" (make-rectangular 0 1) "+1.i" "+1.0i" "0.+1.i" "0.0+1.0i")
271 ("-i" (make-rectangular 0 -1) "-1.i" "-1.0i" "0.-1.i" "0.0-1.0i")
272 ("0-i" (make-rectangular 0 -1) "-1.i" "-1.0i" "0.-1.i" "0.0-1.0i")
273 ("0-1i" (make-rectangular 0 -1) "-1.i" "-1.0i" "0.-1.i" "0.0-1.0i")
274 ("+2i" (make-rectangular 0 2) "+2.0i" "+2.i" "0.+2.i" "0.0+2.0i")
275 ("-2i" (make-rectangular 0 -2) "-2.0i" "-2.i" "0.-2.i" "0.0-2.0i")))
276 (compnums
277 ((exact inexact)
278 ("1#+1#i" (make-rectangular 10.0 10.0) (make-rectangular 15.0 15.0)
279 "10.0+10.0i" "10.+10.i" "15.0+15.0i" "15.+15.i")))
280 ("2i" #f)
281 ("+-i" #f)
282 ("i" #f)
283 ("1+2i1" #f)
284 ("1+2" #f)
285 ("1#+#i" #f)
286
287 (compnums
288 ((exact inexact)
289 "Decimal-notation complex numbers (rectangular notation)"
290 ("1.0+2i" (make-rectangular 1.0 2) "1.0+2.0i" "1.0+2i" "1.+2i" "1.+2.i")
291 ("1+2.0i" (make-rectangular 1 2.0) "1.0+2.0i" "1+2.0i" "1.+2.i" "1+2.i")
292 ("1#.+1#.i" (make-rectangular 10.0 10.0) (make-rectangular 15.0 15.0)
293 "10.0+10.0i" "10.+10.i" "15.0+15.0i" "15.+15.i")
294 ("1e2+1.0i" (make-rectangular 100.0 1.0) "100.0+1.0i" "100.+1.i")
295 ("1s2+1.0i" (make-rectangular 100.0 1.0) "100.0+1.0i" "100.+1.i")
296 ("1.0+1e2i" (make-rectangular 1.0 100.0) "1.0+100.0i" "1.+100.i")
297 ("1.0+1s2i" (make-rectangular 1.0 100.0) "1.0+100.0i" "1.+100.i")
298 ("1#e2+1.0i" (make-rectangular 1000.0 1.0) (make-rectangular 1500.0 1.0)
299 "1000.0+1.0i" "1000.+1.i" "1500.0+1.0i" "1500.+1.i" "1.0e3+1.0i" "15.0e2+1.0i")
300 ("1.0+1#e2i" (make-rectangular 1.0 1000.0) (make-rectangular 1.0 1500.0)
301 "1.0+1000.0i" "1.+1000.i" "1.0+1500.0i" "1.+1500.i" "1.0+1.0e3i" "1.0+15.0e2i")
302 (".i" #f)
303 ("+.i" #f)
304 (".+i" #f)))
305
306 (compnums
307 ((exact)
308 "Fractional complex numbers (rectangular notation)"
309 ("1/2+3/4i" (make-rectangular (/ 1 2) (/ 3 4))))
310 ((inexact)
311 "Fractional complex numbers (rectangular notation)"
312 ("1/2+3/4i" (make-rectangular (/ 1 2) (/ 3 4)) "0.5+0.75i" ".5+.75i" "500.0e-3+750.0e-3i")))
313
314 (compnums
315 ((exact inexact)
316 "Mixed fractional/decimal notation complex numbers (rectangular notation)"
317 ("1#/2+3/4i" (make-rectangular 5.0 (/ 3 4)) (make-rectangular 7.5 (/ 3 4))
318 "5.0+0.75i" "5.+.75i" "7.5+0.75i" "5.0+3/4i" "5.+3/4i" "7.5+3/4i" "5.0+750.0e-3i")
319 ("0.5+3/4i" (make-rectangular 0.5 (/ 3 4))
320 "0.5+0.75i" ".5+.75i" "0.5+3/4i" ".5+3/4i" "500.0e-3+750.0e-3i")
321 ("1.5+1#/4i" (make-rectangular 1.5 2.5) (make-rectangular 1.5 3.75)
322 "1.5+2.5i" "1.5+3.75i")
323 ("0.5+1/#i" #f)
324 ("0.5+1/1#2i" #f)
325 ("1/#+0.5i" #f)
326 ("1/1#2+0.5i" #f)
327
328 "Mixed notation with infinity (might fail on mixed exactness compnums)"
329 ;; This is a nasty one. Switch to inexact *after* reading the first number.
330 ;; Note that it's perfectly acceptable for a scheme with *mixed* exactness
331 ;; in complex values to return #f here. TODO: How to parameterize this, we
332 ;; *really* want to test that single-exactness compnums systems accept this.
333 ("1/0+1.2i" (make-rectangular pos-inf 1.2) "+inf.0+1.2i" "+Inf.0+1.2i")
334 ;; Less nasty, most get this right. Same caveat as above re: mixed exactness
335 ("1.2+1/0i" (make-rectangular 1.2 pos-inf) "1.2+inf.0i" "1.2+Inf.0")))
336
337 (compnums
338 ((exact inexact)
339 "Complex NaN, Inf (rectangular notation)"
340 ("+nan.0+nan.0i" (make-rectangular the-nan the-nan) "+NaN.0+NaN.0i")
341 ("+inf.0+inf.0i" (make-rectangular pos-inf pos-inf) "+Inf.0+Inf.0i")
342 ("-inf.0+inf.0i" (make-rectangular neg-inf pos-inf) "-Inf.0+Inf.0i")
343 ("-inf.0-inf.0i" (make-rectangular neg-inf neg-inf) "-Inf.0-Inf.0i")
344 ("+inf.0-inf.0i" (make-rectangular pos-inf neg-inf) "+Inf.0-Inf.0i")
345
346 "Complex numbers (polar notation)"
347 ;; TODO: Add some here. The problem is the representation
348 ;; is hard to nail down when echoed back as rectangular
349 ;; since they're floating point with many digits, and depend
350 ;; on the precision of PI used internally.
351 ("1@2i" #f)
352 ("0.5@1/#" #f)
353 ("0.5@1/1#2" #f)
354 ("1/#@0.5" #f)
355 ("1/1#2@0.5" #f)
356 ("1@" #f)
357 ("1#@#" #f)
358 ("1/@" #f)
359 ("@/1" #f)
360 ("@1" #f)
361 ("1@+" #f)
362 ("+@1" #f)
363 ("@" #f)))
364
365 "Base prefixes"
366 ("#x11" 17 "17")
367 ("#X11" 17 "17")
368 ("#d11" 11 "11")
369 ("#D11" 11 "11")
370 ("#o11" 9 "9")
371 ("#O11" 9 "9")
372 ("#b11" 3 "3")
373 ("#B11" 3 "3")
374 ("#da1" #f)
375 ("#o8" #f)
376 ("#b2" #f)
377 ("#o7" 7 "7")
378 ("#xa" 10 "10")
379 ("#xA" 10 "10")
380 ("#xf" 15 "15")
381 ("#xg" #f)
382 ("#x-10" -16 "-16")
383 ("#d-10" -10 "-10")
384 ("#o-10" -8 "-8")
385 ("#b-10" -2 "-2")
386 ("-#x10" #f)
387 ("-#d10" #f)
388 ("-#o10" #f)
389 ("-#b10" #f)
390 ("#x-" #f)
391 ("#x" #f)
392 ("#d" #f)
393 ("#d-" #f)
394 ("#d+" #f)
395 ("#o" #f)
396 ("#o-" #f)
397 ("#b" #f)
398 ("#b-" #f)
399 ("#e" #f)
400 ("#e-" #f)
401 ("#i" #f)
402 ("#i-" #f)
403
404 "Combination of prefixes"
405 ("#x#x11" #f)
406 ("#x#b11" #f)
407 ("#b#o11" #f)
408 ("#e#x10" 16 "16")
409 ("#i#x10" 16.0 "16.0" "16.")
410 ("#e#e10" #f)
411 ("#e#e#x10" #f)
412 ("#E#e#X10" #f)
413 ("#i#e#x10" #f)
414 ("#e#x#e10" #f)
415 ("#x#x#e10" #f)
416 ("#x#e#x10" #f)
417
418 "Base prefixes with padding"
419 ("#x1#0" #f)
420 ("#d1#0" #f)
421 ("#o1#0" #f)
422 ("#b1#0" #f)
423 ("#x1#" 16.0 24.0 "16.0" "24.0" "16." "24.")
424 ("#d1#" 10.0 15.0 "10.0" "15.0" "10." "15.")
425 ("#o1#" 8.0 12.0 "8.0" "12.0" "8." "12.")
426 ("#b1#" 2.0 3.0 "2.0" "3.0" "2." "3.")
427
428 "(Attempted) decimal notation with base prefixes"
429 ("#x1.0" #f)
430 ("#d1.0" 1.0 "1.0" "1.")
431 ("#o1.0" #f)
432 ("#b1.0" #f)
433 ("#x1.#" #f)
434 ("#d1.#" 1.0 1.5 "1.0" "1.5" "1.")
435 ("#o1.#" #f)
436 ("#b1.#" #f)
437 ("#x1." #f)
438 ("#d1." 1.0 "1.0" "1.")
439 ("#o1." #f)
440 ("#b1." #f)
441 ("#x.1" #f)
442 ("#d.1" 0.1 "0.1" ".1" "100.0e-3")
443 ("#o.1" #f)
444 ("#b.1" #f)
445 ("#x1e2" 482 "482")
446 ("#d1e2" 100.0 "100.0" "100.")
447 ("#o1e2" #f)
448 ("#b1e2" #f)
449
450 "Fractions with prefixes"
451 (fractions
452 ((inexact)
453 ("#x10/2" 8.0 "8.0" "8.")
454 ("#x11/2" 8.5 "8.5")
455 ("#d11/2" 5.5 "5.5")
456 ("#o11/2" 4.5 "4.5")
457 ("#b11/10" 1.5 "1.5"))
458 ((exact)
459 ("#x10/2" 8 "8")
460 ("#x11/2" (/ 17 2) "17/2")
461 ("#d11/2" (/ 11 2) "11/2")
462 ("#o11/2" (/ 9 2) "9/2")
463 ("#b11/10" (/ 3 2) "3/2")))
464 (fractions
465 ((inexact exact)
466 ("#b11/2" #f)
467 ("#x10/#o10" #f)
468 ("10/#o10" #f)
469 ("#x1#/2" 8.0 12.0 "8.0" "8." "12.0" "12.")
470 ("#d1#/2" 5.0 7.5 "5.0" "5." "7.5")
471 ("#o1#/2" 4.0 6.0 "4.0" "4." "6.0" "6.")
472 ("#b1#/2" #f)
473 ("#b1#/10" 1.0 1.5 "1.0" "1." "1.5")))
474
475 (compnums
476 ((exact inexact)
477 "Complex numbers with prefixes"
478 ("#x1#+1#i" (make-rectangular 16.0 16.0) (make-rectangular 24.0 24.0)
479 "16.0+16.0i" "16.+16.i" "24.0+24.0i" "24.+24.i")
480 ("#x1.0+1.0i" #f)
481 ("#d1.0+1.0i" (make-rectangular 1.0 1.0) "1.0+1.0i" "1.+1.i")
482 ("#o1.0+1.0i" #f)
483 ("#b1.0+1.0i" #f)
484 ("#x10+#o10i" #f)
485 ("10+#o10i" #f)
486 ("#x1@#x1" #f)
487 ("1@#x1" #f)))
488 (compnums
489 ((exact)
490 ("#x10+11i" (make-rectangular 16 17) "16+17i")
491 ("#d10+11i" (make-rectangular 10 11) "10+11i")
492 ("#o10+11i" (make-rectangular 8 9) "8+9i")
493 ("#b10+11i" (make-rectangular 2 3) "2+3i")
494 ("#e1.0+1.0i" (make-rectangular 1 1) "1+1i" "1+i")
495 ("#i1.0+1.0i" (make-rectangular 1.0 1.0) "1.0+1.0i" "1.+1.i"))
496 ((inexact)
497 ("#x10+11i" (make-rectangular 16 17) "16.0+17.0i" "16.+17.i")
498 ("#d10+11i" (make-rectangular 10 11) "10.0+11.0i" "10.+11.i")
499 ("#o10+11i" (make-rectangular 8 9) "8.0+9.0i" "8.+9.i")
500 ("#b10+11i" (make-rectangular 2 3) "2.0+3.0i" "2.+3.i")))
501
502 )
503
504;; #1272 - Bases not in [2,36] throw errors.
505(let ((check-base (lambda (b)
506 (string->number "123" b)
507 (error "No error on invalid base" b))))
508 (condition-case (check-base 1) ((exn type) 'ok))
509 (condition-case (check-base 37) ((exn type) 'ok)))
510
511;; #1627 - Even though R7RS Scheme allows not distinguishing negative
512;; zero (as in the test above), we do.
513(assert (string=? "-0.0" (number->string -0.0)))
514(assert (string=? "0.0" (number->string +0.0)))
515(assert (eqv? -0.0 (string->number "-0.0")))
516(assert (eqv? 0.0 (string->number "+0.0")))
517(assert (eqv? 0.0 (string->number "0.0")))
518(assert (eqv? -0.0 (string->number "-0e1")))
519(assert (eqv? 0.0 (string->number "0e-1")))