david135 / mosh-scheme

Automatically exported from code.google.com/p/mosh-scheme
Other
0 stars 0 forks source link

Mosh doesn't call close procedure when custom port is closed. #170

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

$ cat closeport.ss 
(import (rnrs) (rnrs mutable-strings) (srfi :48)  (srfi :78) (srfi :42)) 

(define done #f)

(define test-port
  (make-custom-textual-input-port "TEST"
    (lambda (string start count)             
      0)
    #f
    #f
    (lambda ()
      (display "closing...\n")
      (set! done #t))))

(check (get-string-n test-port 5) => (eof-object))
(check (begin (close-port test-port) done) => #t)
(check-report)
$ mosh closeport.ss 

What is the expected output? What do you see instead?

I expected both tests to pass, the first with the eof object and the second 
with #t. Instead, I got

(get-string-n test-port 5)
 => #[eof-object]
 ; correct

(begin (close-port test-port) done)
 => #f
 ; *** failed ***
 ; expected result: #t

; *** checks *** : 1 correct, 1 failed. First failed example:

(begin (close-port test-port) done)
 => #f
 ; *** failed ***
 ; expected result: #t

What version of the product are you using? On what operating system?

Mosh 0.2.5 and Mosh commit a3e9df9e510cf57e345c8a1d8321facf07670d4c on Fedora 13

Please provide any additional information below.

The R6RS says "The close procedure (if supplied) should perform any actions 
that are necessary when the input port is closed." I supplied it, but it wasn't 
called.

Original issue reported on code.google.com by ianpric...@gmail.com on 3 Sep 2010 at 6:34

GoogleCodeExporter commented 9 years ago
Thank you for your report.
Fixed and added test.

http://github.com/higepon/mosh/commit/32f012c8e5e06a807d1dc41579cde4f80c149560

Original comment by hige...@gmail.com on 4 Sep 2010 at 5:09