- Timestamp:
- 05/01/20 18:18:42 (9 months ago)
- Location:
- release/5/srfi-19/trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
release/5/srfi-19/trunk/srfi-19-io.scm
r38336 r38668 40 40 (import scheme) 41 41 (import (chicken base)) 42 (import (chicken type)) 42 43 #;(import srfi-6) 43 44 (import (only (srfi 1) drop)) … … 425 426 (define (format-date dest fmt . r) 426 427 (let ( 427 (port #f)428 (port (the (or boolean output-port) #f)) 428 429 (date (optional r #f)) ) 429 430 (cond … … 517 518 518 519 (define (zone-reader port) 519 (let ((offset 0) 520 (is-pos #t) 521 (ch (read-char port)) ) 520 ;NOTE original is-pos & offset were in top let, w/ is-pos value set!, w/ 521 ;-strict-types the compiler assumed is-pos didn't change its' value from the 522 ;initial #t! 523 (define (optdec off fac) 524 (let ((ch (read-char port))) 525 (if (eof-object? ch) 526 off 527 (+ off (* (digit->int ch) fac)))) ) 528 (let ((ch (read-char port))) 522 529 (when (eof-object? ch) 523 (error-bad-date-template 'string->date 524 "invalid time zone +/-" 'eof-object)) 530 (error-bad-date-template 'string->date "invalid time zone +/-" 'eof-object)) 525 531 (if (or (char=? ch #\Z) (char=? ch #\z)) 526 532 0 527 (begin 528 (cond 529 ((char=? ch #\+) (set! is-pos #t)) 530 ((char=? ch #\-) (set! is-pos #f)) 531 (else 532 (error-bad-date-template 'string->date "invalid time zone +/-" ch))) 533 (let ((ch (read-char port))) 534 (when (eof-object? ch) 535 (error-bad-date-template 'string->date 536 "invalid time zone number" 'eof-object)) 537 (set! offset (* (digit->int ch) (* 10 SEC/HR)))) 533 (let* ( 534 (is-pos 535 (cond 536 ((char=? ch #\+) #t) 537 ((char=? ch #\-) #f) 538 (else 539 (error-bad-date-template 'string->date "invalid time zone +/-" ch)))) 540 (offset 541 (let ((ch (read-char port))) 542 (when (eof-object? ch) 543 (error-bad-date-template 'string->date "invalid time zone number" 'eof-object)) 544 (* (digit->int ch) (* 10 SEC/HR)))) 538 545 ;non-existing values are considered zero 539 (let ((ch (read-char port))) 540 (unless (eof-object? ch) 541 (set! offset (+ offset (* (digit->int ch) SEC/HR))))) 542 (let ((ch (read-char port))) 543 (unless (eof-object? ch) 544 (set! offset (+ offset (* (digit->int ch) 600))))) 545 (let ((ch (read-char port))) 546 (unless (eof-object? ch) 547 (set! offset (+ offset (* (digit->int ch) 60))))) 546 (offset (optdec offset SEC/HR)) 547 (offset (optdec offset (* 10 SEC/MIN))) 548 (offset (optdec offset SEC/MIN)) ) 548 549 (if is-pos offset (- offset)))) ) ) 549 550 -
release/5/srfi-19/trunk/srfi-19-tm.scm
r38336 r38668 597 597 ;; Current time routines 598 598 599 ; Throw away everything but the sub-second bit. 600 ; 601 (define (tm:current-sub-milliseconds) 602 (inexact->exact (remainder (current-milliseconds) MS/S)) ) 603 604 (define (tm:current-nanoseconds) 605 (* (tm:current-sub-milliseconds) NS/MS) ) 606 607 ;Use the 'official' seconds & nanoseconds values 608 ; 609 (define (tm:current-time-values) 610 (values (tm:current-nanoseconds) (current-seconds)) ) 599 (import (only srfi-19-tmctm tm:current-time-values)) 611 600 612 601 (define (tm:current-time-utc) -
release/5/srfi-19/trunk/srfi-19.egg
r38295 r38668 2 2 3 3 ((synopsis "Time Data Types and Procedures") 4 (version "4. 4.1")4 (version "4.5.0") 5 5 (category data) 6 6 (author "Will Fitzgerald (for Chicken by [[/users/kon-lovett]])") … … 23 23 "srfi-29-bundles/nl/srfi-19" "srfi-29-bundles/pt/br/srfi-19")) 24 24 (extension srfi-19 25 #;(inline-file)26 25 (types-file) 27 26 (component-dependencies srfi-19-core srfi-19-io srfi-19-literals) 28 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))27 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 29 28 (extension srfi-19-period 30 #;(inline-file)31 29 (types-file) 32 30 (component-dependencies srfi-19-tm srfi-19-core) 33 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))31 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 34 32 (extension srfi-19-literals 35 #;(inline-file)36 33 (types-file) 37 34 (component-dependencies srfi-19-tm srfi-19-core srfi-19-io) 38 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))35 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 39 36 (extension srfi-19-core 40 #;(inline-file)41 37 (types-file) 42 38 (component-dependencies srfi-19-timezone srfi-19-support srfi-19-time srfi-19-date) 43 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))39 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 44 40 (extension srfi-19-io 45 #;(inline-file)46 41 (types-file) 47 42 (component-dependencies srfi-19-support srfi-19-tm srfi-19-timezone) 48 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))43 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 49 44 (extension srfi-19-support 50 #;(inline-file)51 45 (types-file) 52 46 (component-dependencies srfi-19-timezone srfi-19-tm) 53 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))47 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 54 48 (extension srfi-19-time 55 #;(inline-file)56 49 (types-file) 57 50 (component-dependencies srfi-19-support srfi-19-tm) 58 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks"))51 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 59 52 (extension srfi-19-date 60 #;(inline-file)61 53 (types-file) 62 54 (component-dependencies srfi-19-support srfi-19-tm srfi-19-io) 63 (csc-options "-O3" "-d1" "-local" "-no-procedure-checks" "-no-bound-checks")) 55 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) 56 (extension srfi-19-tmctm 57 (types-file) 58 (csc-options "-O4" "-d0" "-strict-types" "-no-procedure-checks" "-no-bound-checks" "-no-argc-checks")) 64 59 (extension srfi-19-tm 65 #;(inline-file)66 60 (types-file) 67 (component-dependencies srfi-19-timezone )68 (csc-options "-O4" "-d 1" "-local" "-no-procedure-checks" "-no-bound-checks" "-no-argc-checks"))61 (component-dependencies srfi-19-timezone srfi-19-tmctm) 62 (csc-options "-O4" "-d0" "-strict-types" "-no-procedure-checks" "-no-bound-checks" "-no-argc-checks")) 69 63 (extension srfi-19-timezone 70 #;(inline-file)71 64 (types-file) 72 (csc-options "-O3" "-d1" "- local" "-no-procedure-checks" "-no-bound-checks")) ) )65 (csc-options "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) ) ) -
release/5/srfi-19/trunk/tests/run.scm
r38455 r38668 9 9 ;chicken-install invokes as "<csi> -s run.scm <eggnam> <eggdir>" 10 10 11 (import (only (chicken pathname) make-pathname)) 11 (import (only (chicken pathname) 12 make-pathname pathname-file pathname-replace-directory pathname-strip-extension)) 12 13 (import (only (chicken process) system)) 13 14 (import (only (chicken process-context) argv)) 14 15 (import (only (chicken format) format)) 16 (import (only (chicken file) file-exists? find-files)) 17 (import (only (chicken irregex) irregex irregex-match?)) 15 18 16 (define (test-filename test-name) 17 (string-append test-name "-test") ) 19 (define *args* (argv)) 18 20 19 21 (define (egg-name args #!optional (def EGG-NAME)) 20 22 (cond 21 ((<= 4 (length *args*)) 22 (cadddr *args*) ) 23 (def 24 def ) 23 ((<= 4 (length *args*)) (cadddr *args*) ) 24 (def def ) 25 25 (else 26 (error 'test "cannot determine egg-name") ) ) ) 27 28 ;; 29 30 (define *args* (argv)) 31 (define *egg* (egg-name *args*)) 32 (define *tests* `(,*egg*)) 26 (error 'run "cannot determine egg-name") ) ) ) 33 27 34 28 (define *current-directory* (cond-expand (unix "./") (else #f))) 29 (define *egg* (egg-name *args*)) 35 30 36 31 ;no -disable-interrupts or -no-lambda-info 37 32 (define *csc-options* "-inline-global -local -inline \ 38 33 -specialize -optimize-leaf-routines -clustering -lfa2 \ 39 -no-trace -unsafe") 34 -no-trace -unsafe \ 35 -strict-types") 40 36 41 (define (run-test-evaluated test-name test-source)42 (format #t "*** ~A - csi ***~%" test-name)43 (system (string-append "csi -s " test-source)))37 (define *test-files-rx* (irregex '(: (+ graph) #\- "test" #\. "scm"))) 38 (define (test-filename name) (string-append name "-test")) 39 (define (test-files) (find-files "." #:test *test-files-rx* #:limit 1)) 44 40 45 (define (run-test-compiled test-name test-source csc-options) 46 (format #t "*** ~A - csc ~A ***~%" test-name csc-options) 41 (define (ensure-test-source-name name) 42 (if (irregex-match? *test-files-rx* name) 43 name 44 (make-pathname *current-directory* (test-filename name) "scm") ) ) 45 46 (define (run-test-evaluated source) 47 (format #t "*** ~A - csi ***~%" (pathname-file source)) 48 (system (string-append "csi -s " source)) ) 49 50 (define (run-test-compiled source csc-options) 51 (format #t "*** ~A - csc ~A ***~%" (pathname-file source) csc-options) 47 52 ;csc output is in current directory 48 (system (string-append "csc" " " csc-options " " test-source))49 (system ( make-pathname *current-directory* (test-filename test-name))) )53 (system (string-append "csc" " " csc-options " " source)) 54 (system (pathname-replace-directory (pathname-strip-extension source) *current-directory*)) ) 50 55 51 56 ;;; 52 57 53 (define (run-test #!optional (test-name *egg*) (csc-options *csc-options*)) 54 (let ((test-source (make-pathname #f (test-filename test-name) "scm"))) 55 (run-test-evaluated test-name test-source) 58 (define (run-test #!optional (name *egg*) (csc-options *csc-options*)) 59 (let ( 60 (source (ensure-test-source-name name)) ) 61 (unless (file-exists? source) 62 (error 'run "no such file" source) ) 63 (run-test-evaluated source) 56 64 (newline) 57 (run-test-compiled test-name test-source csc-options) ) )65 (run-test-compiled source csc-options) ) ) 58 66 59 (define (run-tests #!optional (test -names *tests*) (csc-options *csc-options*))60 (for-each (cut run-test <> csc-options) test -names) )67 (define (run-tests #!optional (tests (test-files)) (csc-options *csc-options*)) 68 (for-each (cut run-test <> csc-options) tests) ) 61 69 62 70 ;;; Do Test -
release/5/srfi-19/trunk/tests/test-gloss.incl.scm
r38433 r38668 1 1 2 ;;; test "Gloss" API2 ;;; test "Gloss" API 3 3 4 (define-constant TEST-GLOSS-MARKER "--> ") 5 6 (define (test-group-ref group field . o) 7 (define (assq-ref ls key . o) 8 (cond 9 ((assq key ls) => cdr) 10 ((pair? o) (car o)) 11 (else #f) ) ) 12 (apply assq-ref (cdr group) field o) ) 4 ;; 13 5 14 6 (define test-indent-width) … … 17 9 (define test-indentation-char) 18 10 (let () 19 (import 20 (chicken syntax) 21 (only (chicken process-context) get-environment-variable)) 11 (import (chicken syntax)) 12 (import (only (chicken process-context) get-environment-variable)) 22 13 23 14 (define get-environment-variable/default … … 90 81 (checked-guard test-indentation-char char))) ) 91 82 83 ;; 84 85 ;from test? 86 (define (test-group-ref group field . o) 87 (define (assq-ref ls key . o) 88 (cond 89 ((assq key ls) => cdr) 90 ((pair? o) (car o)) 91 (else #f) ) ) 92 (apply assq-ref (cdr group) field o) ) 93 94 ;; 95 96 (define-constant TEST-GLOSS-MARKER "--> ") 97 92 98 (define (test-group-indent-string group) 93 99 (define (*test-group-level group) … … 99 105 (make-string (test-group-indent-width group) (test-indentation-char)) ) 100 106 107 (define (display-gloss-marker) 108 (display (test-group-indent-string (current-test-group))) 109 (display TEST-GLOSS-MARKER) ) 110 111 ;; 112 113 (define-syntax glossn 114 (syntax-rules () 115 ((glossn) 116 (begin)) 117 ((glossn ?obj) 118 (begin 119 (display-gloss-marker) 120 (display ?obj) 121 (flush-output)) ) 122 ((glossn ?obj ...) 123 (begin 124 (display-gloss-marker) 125 (for-each display (list ?obj ...)) 126 (flush-output)) ) ) ) 127 101 128 (define-syntax gloss 102 129 (syntax-rules () 103 130 ((gloss) 104 (newline) 131 (newline)) 105 132 ((gloss ?obj ...) 106 133 (begin 107 (display (test-group-indent-string (current-test-group))) 108 (display TEST-GLOSS-MARKER) 109 (for-each display (list ?obj ...)) 134 (glossn ?obj ...) 110 135 (newline)) ) ) ) 111 136 137 ;Needs a format: 112 138 ;(import (only (chicken format) format)) ;builtin 113 139 ;(import format) ;egg 140 141 (define-syntax glossnf 142 (syntax-rules () 143 ((glossnf ?fmt ?arg0 ...) 144 (glossn (format #f ?fmt ?arg0 ...)) ) ) ) 145 114 146 (define-syntax glossf 115 147 (syntax-rules () 116 148 ((glossf ?fmt ?arg0 ...) 117 (gloss (format #f ?fmt ?arg0 ...)) ) ) ) 149 (begin 150 (glossnf ?fmt ?arg0 ...) 151 (newline)) ) ) )
Note: See TracChangeset
for help on using the changeset viewer.