Default args to eliminate-whitespace

This commit is contained in:
Jay McCarthy 2010-06-21 12:43:53 -06:00
parent d6b20a51d2
commit 801419693a
3 changed files with 11 additions and 4 deletions

View File

@ -550,6 +550,12 @@ END
(test-suite (test-suite
"eliminate-whitespace" "eliminate-whitespace"
(test-equal? "Defaults"
(with-output-to-string
(lambda ()
(write-xml/content ((eliminate-whitespace) (read-xml/element (open-input-string "<html>\n<p>Hey</p></html>"))))))
"<html>\n<p>Hey</p></html>")
(test-eliminate-whitespace empty identity "<html>\n<p>Hey</p></html>" "<html>\n<p>Hey</p></html>") (test-eliminate-whitespace empty identity "<html>\n<p>Hey</p></html>" "<html>\n<p>Hey</p></html>")
(test-eliminate-whitespace/exn empty not "<html>\n<p>Hey</p></html>" "not allowed to contain text") (test-eliminate-whitespace/exn empty not "<html>\n<p>Hey</p></html>" "not allowed to contain text")
(test-eliminate-whitespace/exn empty truer "<html>\n<p>Hey</p></html>" "not allowed to contain text") (test-eliminate-whitespace/exn empty truer "<html>\n<p>Hey</p></html>" "not allowed to contain text")

View File

@ -1,10 +1,11 @@
#lang racket #lang racket
(require "structures.rkt") (require "structures.rkt")
(provide/contract (provide/contract
[eliminate-whitespace ((listof symbol?) (boolean? . -> . boolean?) . -> . (element? . -> . element?))]) [eliminate-whitespace (() ((listof symbol?) (boolean? . -> . boolean?)) . ->* . (element? . -> . element?))])
;; eliminate-whitespace : (listof Symbol) (Bool -> Bool) -> Element -> Element ;; eliminate-whitespace : (listof Symbol) (Bool -> Bool) -> Element -> Element
(define (eliminate-whitespace special eliminate-special?) (define (eliminate-whitespace [special empty]
[eliminate-special? (λ (x) x)])
(letrec ([blank-it (letrec ([blank-it
(lambda (el) (lambda (el)
(let ([name (element-name el)] (let ([name (element-name el)]

View File

@ -269,8 +269,8 @@ Converts an @tech{X-expression} into a string containing XML.}
Converts XML represented with a string into an @tech{X-expression}.} Converts XML represented with a string into an @tech{X-expression}.}
@defproc[((eliminate-whitespace [tags (listof symbol?)] @defproc[((eliminate-whitespace [tags (listof symbol?) empty]
[choose (boolean? . -> . boolean?)]) [choose (boolean? . -> . boolean?) (λ (x) x)])
[elem element?]) [elem element?])
element?]{ element?]{