[Gauche-devel-jp] Re: Cygwin(Unix) 上での port-current-line

Back to archive index

HIRAUCHI Hideyuki hira****@verys*****
2004年 2月 15日 (日) 17:00:39 JST


平内です。

たびたびすいません。
formatの出力テストが変だったので修正。

(use gauche.test)

(with-output-to-file "tmp1.o" (lambda () (newline)(newline)(newline)))

(define (port-current-line-tester-r reader)
  (with-input-from-file "tmp1.o"
    (lambda ()
      (do () ((eof-object? (reader))
              (port-current-line (current-input-port)))))))

(test* "port-current-line (read-char)" 4
       (port-current-line-tester-r read-char))

(test* "port-current-line (read-line)" 4
       (port-current-line-tester-r read-line))

(test* "port-current-line (read-byte)" -1
       (port-current-line-tester-r read-byte))

(test* "port-current-line (read-block)" -1
       (port-current-line-tester-r (lambda () (read-block 1))))

(test* "port-current-line (newline)" 4
       (with-output-to-file "tmp1.o"
         (lambda ()
           (newline)(newline)(newline)
           (port-current-line (current-output-port)))))

(define (port-current-line-tester-w writer str)
  (with-output-to-file "tmp1.o"
    (lambda ()
      (for-each (lambda (i) (writer i)(writer str)) '("1" "2" "3"))
      (port-current-line (current-output-port)))))

(test* "port-current-line (display CR)" 4
       (port-current-line-tester-w display " display CR\r"))
(test* "port-current-line (display CRLF)" 4
       (port-current-line-tester-w display " display CRLF\r\n"))
(test* "port-current-line (display LF)" 4
       (port-current-line-tester-w display " display LF\n"))

(test* "port-current-line (format CR)" 4
       (port-current-line-tester-w
         (lambda (i) (format #t "~a" i)) " format CR\r"))
(test* "port-current-line (format CRLF)" 4
       (port-current-line-tester-w
         (lambda (i) (format #t "~a" i)) " format CRLF\r\n"))
(test* "port-current-line (format LF)" 4
       (port-current-line-tester-w
         (lambda (i) (format #t "~a" i)) " format LF\n"))

--hira




Gauche-devel-jp メーリングリストの案内
Back to archive index