More tests and fixes
This commit is contained in:
parent
d27f9cb7cc
commit
4f65284ef9
|
@ -284,10 +284,7 @@
|
|||
(define (skip-whitespace) (skip-whitespace* i))
|
||||
|
||||
(define (read-sequence terminator)
|
||||
(sequence-fold '() accumulate-value reverse terminator))
|
||||
|
||||
(define (accumulate-value acc)
|
||||
(cons (read-value) acc))
|
||||
(sequence-fold '() (lambda (acc) (cons (read-value) acc)) reverse terminator))
|
||||
|
||||
(define (read-dictionary-or-set)
|
||||
(sequence-fold #f
|
||||
|
@ -301,7 +298,7 @@
|
|||
(hash-set (or acc (hash)) k v)]
|
||||
[_ (when (hash? acc) (parse-error "Missing expected key/value separator"))
|
||||
(set-add (or acc (set)) k)]))
|
||||
values
|
||||
(lambda (acc) (or acc (hash)))
|
||||
#\}))
|
||||
|
||||
(define PIPE #\|)
|
||||
|
@ -471,7 +468,7 @@
|
|||
[(== PIPE) (read-char i) (string->symbol (read-string PIPE))]
|
||||
[#\# (match i
|
||||
[(px #px#"^#set\\{" (list _))
|
||||
(sequence-fold (set) accumulate-value values #\})]
|
||||
(sequence-fold (set) (lambda (acc) (set-add acc (read-value))) values #\})]
|
||||
[(px #px#"^#hexvalue\\{" (list _))
|
||||
(decode (read-hex-binary '()) (lambda () (parse-error "Invalid #hexvalue encoding")))]
|
||||
[(px #px#"^#true" (list _))
|
||||
|
@ -633,6 +630,15 @@
|
|||
(cross-check "#base64{SGk}" #"Hi" (#x62 "Hi"))
|
||||
(cross-check "#base64{ S G k }" #"Hi" (#x62 "Hi"))
|
||||
|
||||
(check-equal? (string->preserve "[]") '())
|
||||
(check-equal? (string->preserve "{}") (hash))
|
||||
(check-equal? (string->preserve "\"\"") "")
|
||||
(check-equal? (string->preserve "||") (string->symbol ""))
|
||||
(check-equal? (string->preserve "#set{}") (set))
|
||||
|
||||
(check-equal? (string->preserve "{1 2 3}") (set 1 2 3))
|
||||
(check-equal? (string->preserve "#set{1 2 3}") (set 1 2 3))
|
||||
|
||||
(cross-check "\"abc\\u6c34\\u6C34\\\\\\/\\\"\\b\\f\\n\\r\\txyz\""
|
||||
"abc\u6c34\u6c34\\/\"\b\f\n\r\txyz"
|
||||
(#x5f #x14
|
||||
|
|
Loading…
Reference in New Issue