test-write.rkt (631B)
1 #lang typed/racket 2 3 (require typed-struct-props 4 typed/rackunit) 5 6 (struct/props foo ([f : Number]) #:transparent 7 #:property prop:custom-write 8 (λ (this out mode) 9 (fprintf out "#<f2-instance ~a>" (foo-f this)))) 10 11 (test-not-exn "The structure's constructor and type work properly" 12 (λ () (ann (foo 12) foo))) 13 14 (test-equal? "The structure's constructor and accessor work properly" 15 (ann (foo-f (foo 12)) Number) 16 12) 17 18 (test-equal? "The prop:custom-write is taken into account" 19 (format "~a" (foo 1)) 20 "#<f2-instance 1>")