~williewillus/racket-rfc8949

7980bdaec010ba06570ff08800773500b58fa7cf — Vincent Lee 3 years ago 6930dd9
Export adjustments
4 files changed, 11 insertions(+), 10 deletions(-)

M common.rkt
M decode.rkt
M encode.rkt
M main.rkt
M common.rkt => common.rkt +2 -2
@@ 32,7 32,7 @@
         cbor-config-tag-deserializers
         cbor-config-null-value
         empty-config
         with-tag-deserializer
         with-cbor-tag-deserializer
         with-cbor-null)

(struct cbor-config


@@ 41,7 41,7 @@

(define empty-config (cbor-config #hasheqv() 'null))

(define (with-tag-deserializer config id deser)
(define (with-cbor-tag-deserializer config id deser)
  (define old-handlers (cbor-config-tag-deserializers config))
  (struct-copy
   cbor-config config

M decode.rkt => decode.rkt +4 -5
@@ 4,7 4,7 @@
         "common.rkt")

(provide cbor-read
         default-config)
         cbor-default-config)

(define (expect-byte port)
  (define res (read-byte port))


@@ 201,9 201,9 @@
(define (deserialize-invalid-tag tag _data)
  (error (format "Tag ~a is registered as invalid at the IANA" tag)))

(define default-config
(define cbor-default-config
  (foldl (lambda (p config)
           (with-tag-deserializer config (car p) (cdr p)))
           (with-cbor-tag-deserializer config (car p) (cdr p)))
         empty-config
         (list (cons 2 deserialize-bignum)
               (cons 3 deserialize-bigneg)


@@ 226,12 226,11 @@

(module* test #f
  (require rackunit
           racket/list
           "private/util.rkt"
           "private/test_data.rkt")

  (define (try-bytes bytes)
    (cbor-read default-config (open-input-bytes bytes)))
    (cbor-read cbor-default-config (open-input-bytes bytes)))

  (define (try str)
    (try-bytes (hex-bytes str)))

M encode.rkt => encode.rkt +1 -1
@@ 178,7 178,7 @@
    ; hashes have unspecified ordering, just check that it round trips
    (let* ([data #hash(("a" . "A") ("b" . "B") ("c" . "C") ("d" . "D") ("e" . "E"))]
           [ser (try data)]
           [data2 (cbor-read default-config (open-input-bytes ser))])
           [data2 (cbor-read cbor-default-config (open-input-bytes ser))])
      (check-equal? data2 data)))

  (test-case

M main.rkt => main.rkt +4 -2
@@ 1,7 1,9 @@
#lang racket/base

(require "decode.rkt"
         "encode.rkt")
         "encode.rkt"
         "common.rkt")

(provide (all-from-out "decode.rkt")
         (all-from-out "encode.rkt"))
         (all-from-out "encode.rkt")
         (all-from-out "common.rkt"))