Port implementation over racket ports.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#lang racket/base
|
||||
|
||||
(require rackunit
|
||||
racket/serialize
|
||||
port-channel)
|
||||
|
||||
(serializable-struct msg (id payload) #:transparent)
|
||||
|
||||
(define-values (in out) (make-pipe))
|
||||
(define reader (make-port-channel in #:source 'test-reader))
|
||||
(define writer (make-port-channel out #:source 'test-writer))
|
||||
|
||||
(port-channel-put writer '(hello 1 2 3))
|
||||
(port-channel-put writer (hasheq 'a 10 'b 20))
|
||||
(port-channel-put writer (msg 7 '(a b c)))
|
||||
|
||||
(check-equal? (sync reader) '(hello 1 2 3))
|
||||
(check-equal? (sync reader) (hasheq 'a 10 'b 20))
|
||||
(check-equal? (sync reader) (msg 7 '(a b c)))
|
||||
|
||||
(close-port-channel writer)
|
||||
(check-true (eof-object? (sync reader)))
|
||||
|
||||
(module+ main
|
||||
(displayln "port-channel tests ok"))
|
||||
Reference in New Issue
Block a user