for #2058, issue discovered by Sam

This commit is contained in:
Matthias Felleisen 2018-06-25 14:06:48 -04:00
parent a6e6bc0ebd
commit 5bb837661c
2 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,9 @@
#lang at-exp racket/base
;; Mathias, added test for contracts on read-json
(require json racket/string tests/eli-tester)
(require racket/port)
(define T string-append)
@ -114,6 +117,9 @@
(string->jsexpr @T{ " \b\n\r\f\t\\\"\/ " }) => " \b\n\r\f\t\\\"/ "
(string->jsexpr @T{ "\uD834\uDD1E" }) => "\U1D11E"
(string->jsexpr @T{ "\ud834\udd1e" }) => "\U1d11e"
;; INPUT PORT is optional
(with-input-from-string "[]" read-json)
=> (parameterize ((json-null '())) (json-null))
;; EOF detection
(for/list ([je (in-port read-json
(open-input-string

View File

@ -3,7 +3,9 @@
;; Roughly based on the PLaneT package by Dave Herman,
;; Originally released under MIT license.
;; edited: Matthias, organization in preparation for pretty-print
;; edited:
;; -- Matthias, organization in preparation for pretty-print
;; -- Matthias, contracts
;; -----------------------------------------------------------------------------
;; DEPENDENCIES
@ -30,8 +32,8 @@
#:encode (or/c 'control 'all)) ;; 'control
any)]
[read-json
(->* (input-port?)
(#:null any/c) ;; (json-null)
(->* ()
(input-port? #:null any/c) ;; (json-null)
any)] ;; jsexpr?
[jsexpr->string
(->* (any/c) ;; jsexpr? but dependent on #:null arg