Skip to content

Commit

Permalink
Improve error message and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
anttih committed May 25, 2024
1 parent 0540bb2 commit 46648dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion json/src/JSON/Internal.ss
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
(fxsll (fx- w1 #xD800) 10)
(fx- w2 #xDC00))
#x10000)
(error #f (format "Invalid unicode surrogate pair ~a ~a" w1 w2))))]
(error #f (format "Invalid unicode surrogate pair ~,x ~,x" w1 w2))))]
[(fx<= #xDC00 w1 #xDFFF)
(error #f (format "Invalid unicode escape ~,x" w1))]
[else w1])))
Expand Down
1 change: 1 addition & 0 deletions json/test/Main.ss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
(assert-roundtrip "\" \\uD801\\uDC37 foo\"" "\" 𐐷 foo\"")
(assert-fail "\"\\uD801 \"" "Unexpected ' ', was expecting '\\'")
(assert-fail "\"\\uDC37 \"" "Invalid unicode escape DC37")
(assert-fail "\" \\uD801\\uD802 foo\"" "Invalid unicode surrogate pair D801 D802")

(display " Leading whitespace\n")
(assert-roundtrip "\n\r \"\\nbar\"" "\"\\nbar\"")
Expand Down

0 comments on commit 46648dd

Please sign in to comment.