kahl

R⁷RS Scheme parser combinator library for decoding BARE messages

git clone https://git.8pit.net/kahl.git

 1(include "./tests/test-vectors/schema.scm")
 2
 3(define (parse-file f fn)
 4  (let* ((p (string-append "./tests/test-vectors/" fn))
 5         (s (make-parse-stream p)))
 6    (parse f s)))
 7
 8(test "customer.bin"
 9  #("James Smith"              ;; name
10    "jsmith@example.org"       ;; email
11    #(
12      ("123 Main St" "" "" "") ;; address
13      "Philadelphia"           ;; city
14      "PA"                     ;; state
15      "United States"          ;; country
16     )
17    (#(4242424242 5))          ;; orders
18    ())                        ;; metadata
19  (parse-file parse-person "customer.bin"))
20
21(test "employee.bin"
22  '#("Tiffany Doe"               ;; name
23     "tiffanyd@acme.corp"        ;; email
24     #(
25       ("123 Main St" "" "" "")  ;; address
26       "Philadelphia"            ;; city
27       "PA"                      ;; state
28       "United States"           ;; country
29      )
30     1                           ;; department
31     "2020-06-21T21:18:05+00:00" ;; hireDate
32     nothing                     ;; publicKey
33     ())                         ;; metadata
34  (parse-file parse-person "employee.bin"))
35
36(test "terminated.bin"
37      'void
38      (parse-file parse-person "terminated.bin"))