From a003b3ea6e94b01db8b8935d96c2eff4ceaade72 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 15 May 2017 08:45:41 -0700 Subject: [PATCH] improve testing harness --- pitfall/pitfall/out copy.pdf | 63 ----------------------- pitfall/pitfall/out.pdf | 63 ----------------------- pitfall/pitfall/pdftest.rkt | 17 +++++++ pitfall/pitfall/racket.rkt | 2 +- pitfall/pitfall/test/test0.rkt | 12 ++--- pitfall/pitfall/test/test1.rkt | 14 ++---- pitfall/pitfall/test0rkt.pdf | 63 ----------------------- pitfall/pitfall/test1rkt.pdf | 91 ---------------------------------- 8 files changed, 27 insertions(+), 298 deletions(-) delete mode 100644 pitfall/pitfall/out copy.pdf delete mode 100644 pitfall/pitfall/out.pdf create mode 100644 pitfall/pitfall/pdftest.rkt delete mode 100644 pitfall/pitfall/test0rkt.pdf delete mode 100644 pitfall/pitfall/test1rkt.pdf diff --git a/pitfall/pitfall/out copy.pdf b/pitfall/pitfall/out copy.pdf deleted file mode 100644 index f84357ef..00000000 --- a/pitfall/pitfall/out copy.pdf +++ /dev/null @@ -1,63 +0,0 @@ -%PDF-1.3 -%ÿÿÿÿ -5 0 obj -<< -/Parent 1 0 R -/Resources 4 0 R -/Contents 3 0 R -/MediaBox [0 0 612 792] -/Type /Page ->> -endobj -4 0 obj -<< -/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] ->> -endobj -3 0 obj -<< -/Length 18 ->> -stream -1 0 0 -1 0 792 cm - -endstream -endobj -6 0 obj -<< -/CreationDate (D:19700101000000Z) -/Creator (PitfallKit) -/Producer (PitfallKit) ->> -endobj -2 0 obj -<< -/Pages 1 0 R -/Type /Catalog ->> -endobj -1 0 obj -<< -/Kids [5 0 R] -/Count 1 -/Type /Pages ->> -endobj -xref -0 7 -0000000000 65535 f -0000000403 00000 n -0000000354 00000 n -0000000186 00000 n -0000000119 00000 n -0000000015 00000 n -0000000254 00000 n -trailer -<< -/Info 6 0 R -/Root 2 0 R -/Size 7 ->> -startxref -460 -%%EOF diff --git a/pitfall/pitfall/out.pdf b/pitfall/pitfall/out.pdf deleted file mode 100644 index 028a593f..00000000 --- a/pitfall/pitfall/out.pdf +++ /dev/null @@ -1,63 +0,0 @@ -%PDF-1.3 -%ÿÿÿÿ -5 0 obj -<< -/Parent 1 0 R -/Resources 4 0 R -/Contents 3 0 R -/MediaBox [0 0 612 792] -/Type /Page ->> -endobj -4 0 obj -<< -/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] ->> -endobj -3 0 obj -<< -/Length 18 ->> -stream -1 0 0 -1 0 792 cm - -endstream -endobj -6 0 obj -<< -/CreationDate (D:20170514163610Z) -/Creator (PitfallKit) -/Producer (PitfallKit) ->> -endobj -2 0 obj -<< -/Pages 1 0 R -/Type /Catalog ->> -endobj -1 0 obj -<< -/Kids [5 0 R] -/Count 1 -/Type /Pages ->> -endobj -xref -0 7 -0000000000 65535 f -0000000403 00000 n -0000000354 00000 n -0000000186 00000 n -0000000119 00000 n -0000000015 00000 n -0000000254 00000 n -trailer -<< -/Info 6 0 R -/Root 2 0 R -/Size 7 ->> -startxref -460 -%%EOF diff --git a/pitfall/pitfall/pdftest.rkt b/pitfall/pitfall/pdftest.rkt new file mode 100644 index 00000000..1424f709 --- /dev/null +++ b/pitfall/pitfall/pdftest.rkt @@ -0,0 +1,17 @@ +#lang pitfall/racket +(provide (all-from-out pitfall/racket)) + +(test-mode #t) + +(r+p rackunit racket/runtime-path pitfall/document) + +(define (this->control this) (path-add-extension this #"" #" copy.")) + +(provide check-copy-equal?) +(define-syntax-rule (check-copy-equal? this) + (check-equal? (file->bytes this) (file->bytes (this->control this)))) + +(module reader syntax/module-reader + #:language 'pitfall/pdftest + #:read read + #:read-syntax read-syntax) \ No newline at end of file diff --git a/pitfall/pitfall/racket.rkt b/pitfall/pitfall/racket.rkt index 13cda9af..b71124bb 100644 --- a/pitfall/pitfall/racket.rkt +++ b/pitfall/pitfall/racket.rkt @@ -1,5 +1,5 @@ #lang racket/base -(provide (all-from-out racket/base)) +(provide (all-from-out racket/base) r+p) (define-syntax-rule (r+p id ...) (begin (require id ...) (provide (all-from-out id ...)))) diff --git a/pitfall/pitfall/test/test0.rkt b/pitfall/pitfall/test/test0.rkt index a6de6505..19368075 100644 --- a/pitfall/pitfall/test/test0.rkt +++ b/pitfall/pitfall/test/test0.rkt @@ -1,14 +1,10 @@ -#lang pitfall/racket -(require pitfall/document rackunit) +#lang pitfall/pdftest +(define-runtime-path this "test0rkt.pdf") -(test-mode #t) (check-true (let () (define doc (new PDFDocument)) - (send doc pipe (open-output-file "test0rkt.pdf" #:exists 'replace)) + (send doc pipe (open-output-file this #:exists 'replace)) (send doc end))) -(require racket/runtime-path) -(define-runtime-path this "test0rkt.pdf") -(define-runtime-path control "test0rkt copy.pdf") -(check-equal? (file->bytes this) (file->bytes control)) \ No newline at end of file +(check-copy-equal? this) \ No newline at end of file diff --git a/pitfall/pitfall/test/test1.rkt b/pitfall/pitfall/test/test1.rkt index b79d5360..e96435d9 100644 --- a/pitfall/pitfall/test/test1.rkt +++ b/pitfall/pitfall/test/test1.rkt @@ -1,16 +1,10 @@ -#lang pitfall/racket - -(require pitfall/document rackunit) - -(require racket/runtime-path) +#lang pitfall/pdftest (define-runtime-path this "test1rkt.pdf") -(define-runtime-path control "test1rkt copy.pdf") -;; Create a new PDFDocument -(test-mode #t) (check-true (let ([doc (new PDFDocument)]) (send doc pipe (open-output-file this #:exists 'replace)) + ;; Draw a triangle and a circle (send* doc [save] @@ -18,9 +12,11 @@ [lineTo 100 250] [lineTo 200 250] [fill "#FF3300"]) + (send* doc [circle 280 200 50] [fill "#6600FF"]) + (send doc end))) -(check-equal? (file->bytes this) (file->bytes control)) \ No newline at end of file +(check-copy-equal? this) \ No newline at end of file diff --git a/pitfall/pitfall/test0rkt.pdf b/pitfall/pitfall/test0rkt.pdf deleted file mode 100644 index f84357ef..00000000 --- a/pitfall/pitfall/test0rkt.pdf +++ /dev/null @@ -1,63 +0,0 @@ -%PDF-1.3 -%ÿÿÿÿ -5 0 obj -<< -/Parent 1 0 R -/Resources 4 0 R -/Contents 3 0 R -/MediaBox [0 0 612 792] -/Type /Page ->> -endobj -4 0 obj -<< -/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] ->> -endobj -3 0 obj -<< -/Length 18 ->> -stream -1 0 0 -1 0 792 cm - -endstream -endobj -6 0 obj -<< -/CreationDate (D:19700101000000Z) -/Creator (PitfallKit) -/Producer (PitfallKit) ->> -endobj -2 0 obj -<< -/Pages 1 0 R -/Type /Catalog ->> -endobj -1 0 obj -<< -/Kids [5 0 R] -/Count 1 -/Type /Pages ->> -endobj -xref -0 7 -0000000000 65535 f -0000000403 00000 n -0000000354 00000 n -0000000186 00000 n -0000000119 00000 n -0000000015 00000 n -0000000254 00000 n -trailer -<< -/Info 6 0 R -/Root 2 0 R -/Size 7 ->> -startxref -460 -%%EOF diff --git a/pitfall/pitfall/test1rkt.pdf b/pitfall/pitfall/test1rkt.pdf deleted file mode 100644 index 6e454228..00000000 --- a/pitfall/pitfall/test1rkt.pdf +++ /dev/null @@ -1,91 +0,0 @@ -%PDF-1.3 -%ÿÿÿÿ -6 0 obj -<< -/ca 1 -/Type /ExtGState ->> -endobj -5 0 obj -<< -/Parent 1 0 R -/Resources 4 0 R -/Contents 3 0 R -/MediaBox [0 0 612 792] -/Type /Page ->> -endobj -4 0 obj -<< -/ExtGState << -/Gs1 6 0 R ->> -/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] ->> -endobj -3 0 obj -<< -/Length 238 ->> -stream -1 0 0 -1 0 792 cm -q -100 150 m -100 250 l -200 250 l -/DeviceRGB cs -1 0.2 0 scn -/Gs1 gs -f -230 200 m -230 150 230 150 280 150 c -330 150 330 150 330 200 c -330 250 330 250 280 250 c -230 250 230 250 230 200 c -h -/DeviceRGB cs -0.4 0 1 scn -/Gs1 gs -f - -endstream -endobj -7 0 obj -<< -/CreationDate (D:19700101000000Z) -/Creator (PitfallKit) -/Producer (PitfallKit) ->> -endobj -2 0 obj -<< -/Pages 1 0 R -/Type /Catalog ->> -endobj -1 0 obj -<< -/Kids [5 0 R] -/Count 1 -/Type /Pages ->> -endobj -xref -0 8 -0000000000 65535 f -0000000696 00000 n -0000000647 00000 n -0000000258 00000 n -0000000163 00000 n -0000000059 00000 n -0000000015 00000 n -0000000547 00000 n -trailer -<< -/Info 7 0 R -/Root 2 0 R -/Size 8 ->> -startxref -753 -%%EOF