unstable: removed byte-counting-port.rkt (use open-output-nowhere instead)

updated test to verify that open-output-nowhere has same behavior
This commit is contained in:
Ryan Culpepper 2010-06-30 14:00:09 -06:00
parent 7473cf624e
commit a543c2137e
5 changed files with 5 additions and 42 deletions

View File

@ -1,6 +1,6 @@
#lang scheme/base
(require compiler/zo-structs
unstable/byte-counting-port
scheme/port
scheme/match
scheme/contract
scheme/local
@ -68,7 +68,7 @@
(out-data (list* max-let-depth prefix (protect-quote form))
(make-out outp (lambda (v) (hash-ref shared v #f)) wrapped))
(values offsets post-shared (file-position outp)))
(define counting-p (make-byte-counting-port))
(define counting-p (open-output-nowhere))
(define-values (offsets post-shared all-forms-length)
(write-all counting-p))
(define all-short? (post-shared . < . #xFFFF))

View File

@ -1,9 +1,9 @@
#lang racket
(require unstable/byte-counting-port
(require racket/port
tests/eli-tester)
(define name (gensym))
(define cp (make-byte-counting-port name))
(define cp (open-output-nowhere name))
(define (test-cp cp)
(for/fold ([l 0])
([i (in-range 100)])
@ -15,4 +15,4 @@
(test
(object-name cp) => name
(test-cp cp)
(test-cp (make-byte-counting-port)))
(test-cp (open-output-nowhere)))

View File

@ -1,21 +0,0 @@
#lang racket
(define (make-byte-counting-port [name 'byte-counting-port])
(define location 0)
(define (write-out bs starting ending opt1 opt2)
(define how-many-written (- ending starting))
(set! location (+ location how-many-written))
how-many-written)
(define close void)
(define (get-location)
(values #f #f location))
(make-output-port name always-evt write-out close
#f #f #f
get-location))
;; Ryan: Isn't this just a reimplementation of 'open-output-nowhere'?
;; Actually, the 'get-location' method isn't called unless 'port-count-lines!'
;; is called first, and on a fresh port (no writes), it errors because it returns
;; 0 and a positive number is required.
(provide/contract
[make-byte-counting-port (() (any/c) . ->* . output-port?)])

View File

@ -1,15 +0,0 @@
#lang scribble/manual
@(require "utils.rkt" (for-label racket unstable/byte-counting-port))
@title{Byte Counting Ports}
@defmodule[unstable/byte-counting-port]
@unstable[@author+email["Jay McCarthy" "jay@racket-lang.org"]]
This library provides an output port constructor like @racket[open-output-nowhere], except it counts how many bytes have been written (available through @racket[file-position].)
@defproc[(make-byte-counting-port [name any/c 'byte-counting-port])
output-port?]{
Creates and returns an output port that discards all output sent to it (without blocking.) The @racket[name] argument is used as the port's name. The total number bytes written is available through @racket[file-position].}

View File

@ -113,7 +113,6 @@ Keep documentation and tests up to date.
@include-section["generics.scrbl"]
@include-section["markparam.scrbl"]
@include-section["debug.scrbl"]
@include-section["byte-counting-port.scrbl"]
@;{--------}