www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

test-write-poly.rkt (644B)


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