Explore struct inheritance

This commit is contained in:
Tony Garnock-Jones 2018-08-21 10:54:17 +01:00
parent 7dacb5ba6e
commit 542d0a886a
1 changed files with 24 additions and 0 deletions

View File

@ -320,4 +320,28 @@
(check-equal? (d (bytes version 131 2 0 0)) 131072)
(check-equal? (d (bytes version #b11000010 #b00111111 #b10000000 0 0)) 1.0)
(check-equal? (d (bytes version #b11000011 #b00111111 #b11110000 0 0 0 0 0 0)) 1.0)
(struct date (year month day) #:prefab)
(struct thing (id) #:prefab)
(struct person thing (name date-of-birth) #:prefab)
(struct titled person (title) #:prefab)
(check-equal? (encode (titled 101 "Blackwell" (date 1821 2 3) "Dr"))
(bytes version
#x35 ;; struct, generic, 4+1
#x45 ;; list, 5
#xb6 #x74 #x69 #x74 #x6c #x65 #x64 ;; symbol, "titled"
#xb6 #x70 #x65 #x72 #x73 #x6f #x6e ;; symbol, "person"
#x81 #x02 ;; integer, "2"
#xb5 #x74 #x68 #x69 #x6e #x67 ;; symbol, "thing"
#x81 #x01 ;; integer, "1"
#x81 #x65 ;; integer, "101"
#x99 #x42 #x6c #x61 #x63 #x6b #x77 #x65 #x6c #x6c ;; string, "Blackwell"
#x34 ;; struct, generic, 3+1
#xb4 #x64 #x61 #x74 #x65 ;; symbol, "date"
#x82 #x07 #x1d ;; integer, "1821"
#x81 #x02 ;; integer, "2"
#x81 #x03 ;; integer, "3"
#x92 #x44 #x72 ;; string, "Dr"
))
)