scribble/decode: fix contract on `decode-compound-paragraph'

Add a test suite that at least tries each export of `scribble/decode'.

Merge to v5.3.2

original commit: 5ab048bb5cd05fa109b990bb73bc7033b09230ee
This commit is contained in:
Matthew Flatt 2013-01-09 18:32:12 -07:00
parent c7f0f37159
commit cce0a1c62c
2 changed files with 53 additions and 1 deletions

View File

@ -73,7 +73,7 @@
[decode-paragraph (-> (listof pre-content?)
paragraph?)]
[decode-compound-paragraph (-> (listof pre-flow?)
paragraph?)]
block?)]
[decode-content (-> (listof pre-content?)
content?)]
[rename decode-content decode-elements

View File

@ -0,0 +1,52 @@
#lang racket/base
(require scribble/decode
scribble/core
rackunit
racket/contract/base)
(check-true (pre-content? "x"))
(check-true (pre-content? null))
(check-true (pre-content? '("x")))
(check-true (pre-content? (list (element plain "x") "x")))
(check-true (pre-content? (splice (list (element plain "x") "x"))))
(check-true (not (pre-content? 11)))
(check-true (not (pre-content? '(11))))
(check-true (pre-flow? "x"))
(check-true (pre-flow? '("x")))
(check-true (pre-flow? (list (element plain "x") "x")))
(check-true (pre-flow? (list (paragraph plain (element plain "x")) (element plain "x") "x")))
(check-true (pre-flow? (splice (list (paragraph plain (element plain "x")) (element plain "x") "x"))))
(check-true (not (pre-flow? 11)))
(check-true (not (pre-flow? '(11))))
(check-true (pre-part? "x"))
(check-true (pre-part? '("x")))
(check-true (pre-part? (list (element plain "x") "x")))
(check-true (pre-part? (list (paragraph plain (element plain "x")) (element plain "x") "x")))
(check-true (pre-part? (list (paragraph plain (element plain "x")) (element plain "x") "x"
(decode-part '("x") null #f 0)
(part-start 0 #f null plain "start")
(part-index-decl '("a" "b") '("a"))
(part-collect-decl (element plain "x"))
(part-tag-decl '(something "x"))
(void)
(title-decl #f null #f plain "title"))))
(check-true (not (pre-part? 11)))
(check-true (not (pre-part? '(11))))
(check-true (part? (decode '("x"))))
(check-true (part? (decode-part '("x") null #f 0)))
(check-true (andmap block? (decode-flow '("x"))))
(check-true (block? (decode-compound-paragraph '("x"))))
(check-true (paragraph? (decode-paragraph '("x"))))
(check-true (content? (decode-content '("x"))))
(check-true (content? (decode-elements '("x"))))
(check-true (content? (decode-string "x")))
(check-true (whitespace? " \n\t\r"))
(check-true (not (whitespace? " \n\t\rx ")))
(check-equal? "a b c" (clean-up-index-string " a b c "))
(check-true (contract? (spliceof integer?)))