From 8e11af812fd4f4c52109fd35720d917d8d76e3e6 Mon Sep 17 00:00:00 2001 From: JackFirth Date: Sun, 22 Feb 2015 20:51:23 -0800 Subject: [PATCH] Split and test check messages from check forms --- doc-coverage/export-tests.rkt | 38 +++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/doc-coverage/export-tests.rkt b/doc-coverage/export-tests.rkt index 1767ece..ae411ab 100644 --- a/doc-coverage/export-tests.rkt +++ b/doc-coverage/export-tests.rkt @@ -23,13 +23,25 @@ (string-join (map symbol->string undocumented) "\n"))) +(module+ test + (check string=? + (check-all-documented-message 'foo 8 '(foo1 foo2 foo3)) + "Module foo has 8 undocumented bindings:\n\nfoo1\nfoo2\nfoo3")) + (define-check (check-documented module-name binding) (unless (has-docs? module-name binding) - (fail-check - (string-append "Module " - (symbol->string module-name) - " does not document binding " - (symbol->string binding))))) + (fail-check (check-documented-message module-name binding)))) + +(define (check-documented-message module-name binding) + (string-append "Module " + (symbol->string module-name) + " does not document binding " + (symbol->string binding))) + +(module+ test + (check string=? + (check-documented-message 'foo 'foo1) + "Module foo does not document binding foo1")) (define-check (check-documentation-ratio module-name minimum-ratio) (let ([actual-ratio (module-documentation-ratio module-name)]) @@ -41,4 +53,18 @@ (number->string (exact->inexact (* 100 minimum-ratio))) "% of its bindings, only documents " (number->string (exact->inexact (* 100 actual-ratio))) - "%"))))) \ No newline at end of file + "%"))))) + +(define (check-documentation-ratio-message module-name minimum-ratio actual-ratio) + (string-append "Module " + (symbol->string module-name) + " does not document at least " + (number->string (exact->inexact (* 100 minimum-ratio))) + "% of its bindings, only documents " + (number->string (exact->inexact (* 100 actual-ratio))) + "%")) + +(module+ test + (check string=? + (check-documentation-ratio-message 'foo 0.5 0.25) + "Module foo does not document at least 50.0% of its bindings, only documents 25.0%")) \ No newline at end of file