Changeset 26079 in project


Ignore:
Timestamp:
03/06/12 21:47:42 (8 years ago)
Author:
sjamaan
Message:

numbers: Clean up the string conversion part of the tests by simplifying the macro and delegating to a procedure instead (TODO: rework the chicken test suite's version of it as well). This brings down compilation time by half!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/tests/string-conversion.scm

    r25178 r26079  
    4545
    4646(define total-errors 0)
     47
     48(define (check-string-against-values! str . possible-values)
     49  (let ((res (string->number str)))
     50    (let lp ((values possible-values))
     51      (if (null? values)
     52          (begin (display       "PARSE ERROR         ")
     53                 (write (cons str possible-values))
     54                 (display " => ") (write res) (newline)
     55                 (set! total-errors (+ total-errors 1)))
     56          (let ((value (car values)))
     57            (if (not (or (and (not (string? value)) (equal? res value))
     58                         (and res (nan? res) (or (and value (nan? value))))))
     59                (lp (cdr values))
     60                (let ((re-str (and res (number->string res))))
     61                  (let lp2 ((values possible-values))
     62                    (if (null? values)
     63                        (begin (display "SERIALIZATION ERROR ")
     64                               (write (cons str possible-values))
     65                               (display " => ") (write re-str) (newline)
     66                               (set! total-errors (+ total-errors 1)))
     67                        (let ((value (car values)))
     68                          (if (not (or (and res (string=? re-str str))
     69                                       (and (not res) (not value))
     70                                       (and res (string? value) (string=? re-str value))))
     71                              (lp2 (cdr values))
     72                              (begin (display "OK                  ")
     73                                     (write (cons str possible-values))
     74                                     (newline)))))))))))))
    4775
    4876;; Here comes a horrible nasty hack.  It seems to work though ;)
     
    5987    ((_ (str value ...) rest ...)
    6088     (begin
    61        (let ((res (string->number str)))
    62          (if (not (or (and (not (string? value)) (equal? res value)) ...
    63                       (and res (nan? res) (or (and value (nan? value)) ...))))
    64              (begin (display       "PARSE ERROR         ")
    65                     (write '(str value ...))
    66                     (display " => ") (write res) (newline)
    67                     (set! total-errors (+ total-errors 1)))
    68              (let ((re-str (and res (number->string res))))
    69                (if (not (or (and res (string=? re-str str))
    70                             (and (not res) (not value)) ...
    71                             (and res (string? value) (string=? re-str value)) ...))
    72                    (begin (display "SERIALIZATION ERROR ")
    73                           (write `(str value ...))
    74                           (display " => ") (write re-str) (newline)
    75                           (set! total-errors (+ total-errors 1)))
    76                    (begin (display "OK                  ")
    77                           (write '(str value ...)) (newline))))))
     89       (check-string-against-values! str value ...)
    7890       (test-numbers rest ...)))
    7991    ((_ "no-totals") #f)
Note: See TracChangeset for help on using the changeset viewer.