More tests, coverage and fixes

This commit is contained in:
Tony Garnock-Jones 2018-09-27 23:14:43 +01:00
parent 5f9f2175f0
commit d267f65b71
1 changed files with 19 additions and 2 deletions

View File

@ -373,7 +373,7 @@
(define n1 (string->number (bytes->string/utf-8 hexdigits) 16))
(if (<= #xd800 n1 #xdfff) ;; surrogate pair first half
(match i
[(px #px#"^\\\\u([a-fA-F0-9]{4})" (list hexdigits2))
[(px #px#"^\\\\u([a-fA-F0-9]{4})" (list _ hexdigits2))
(define n2 (string->number (bytes->string/utf-8 hexdigits2) 16))
(if (<= #xdc00 n2 #xdfff)
(+ (arithmetic-shift (- n1 #xd800) 10)
@ -396,7 +396,7 @@
(lambda ()
(match i
[(px #px#"^[a-fA-F0-9]{2}" (list hexdigits))
(string->number (bytes->string/utf-8 hexdigits))]
(string->number (bytes->string/utf-8 hexdigits) 16)]
[_ (parse-error "Bad binary \\x escape")]))))
(define (read-intpart acc-rev)
@ -641,6 +641,23 @@
#xb4 #x5c #x2f #x22 #x08 #x0c #x0a #x0d
#x09 #x78 #x79 #x7a))
(cross-check "|abc\\u6c34\\u6C34\\\\\\/\\|\\b\\f\\n\\r\\txyz|"
(string->symbol "abc\u6c34\u6c34\\/|\b\f\n\r\txyz")
(#x7f #x14
#x61 #x62 #x63 #xe6 #xb0 #xb4 #xe6 #xb0
#xb4 #x5c #x2f #x7c #x08 #x0c #x0a #x0d
#x09 #x78 #x79 #x7a))
(check-exn #px"Invalid escape code \\\\u" (lambda () (string->preserve "#\"\\u6c34\"")))
(cross-check "#\"abc\\x6c\\x34\\xf0\\\\\\/\\\"\\b\\f\\n\\r\\txyz\""
#"abc\x6c\x34\xf0\\/\"\b\f\n\r\txyz"
(#x6f #x11
#x61 #x62 #x63 #x6c #x34 #xf0 #x5c #x2f
#x22 #x08 #x0c #x0a #x0d #x09 #x78 #x79 #x7a))
(cross-check "\"\\uD834\\uDD1E\"" "\U0001D11E" (#x54 #xF0 #x9D #x84 #x9E))
(cross-check "-257" -257 (#x42 #xFE #xFF))
(cross-check "-256" -256 (#x42 #xFF #x00))
(cross-check "-255" -255 (#x42 #xFF #x01))