From f090fd07489e74ddac0fb3df1a61249ac42f6500 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 20 Nov 2018 14:29:40 -0800 Subject: [PATCH] test 2 & 3 --- pitfall/pitfall/check-pdf.rkt | 26 ++++-- pitfall/ptest/test2.pdf | 2 +- pitfall/ptest/test2c.pdf | Bin 1235 -> 1235 bytes pitfall/ptest/test2crkt.pdf | Bin 0 -> 1235 bytes pitfall/ptest/test2rkt.pdf | 158 ++++++++++++++++++++++++++++++++++ pitfall/ptest/test3.pdf | 2 +- pitfall/ptest/test3c.pdf | Bin 914 -> 914 bytes pitfall/ptest/test3crkt.pdf | Bin 0 -> 914 bytes pitfall/ptest/test3rkt.pdf | 83 ++++++++++++++++++ 9 files changed, 263 insertions(+), 8 deletions(-) create mode 100644 pitfall/ptest/test2crkt.pdf create mode 100644 pitfall/ptest/test2rkt.pdf create mode 100644 pitfall/ptest/test3crkt.pdf create mode 100644 pitfall/ptest/test3rkt.pdf diff --git a/pitfall/pitfall/check-pdf.rkt b/pitfall/pitfall/check-pdf.rkt index ed2a057b..c1849872 100644 --- a/pitfall/pitfall/check-pdf.rkt +++ b/pitfall/pitfall/check-pdf.rkt @@ -78,7 +78,8 @@ ["\\s+" (parse-1 ip)] ; whitespace ["\\d+ 0 obj" (parse-1 ip)] ;; obj name ["\\d+ 0 R"] ; xref - ["[-]?\\d+"] ; number + ["[-]?\\d*\\.\\d+"] ; real + ["[-]?\\d+\\.?"] ; integer ["\\(.*?\\)"] ; parenstring ["/\\S+"] ; keystring [else eof])])) @@ -107,11 +108,24 @@ (cons idx (parse-pdf-bytes (peek-bytes (- end start) start))))) < #:key car)) +(define (dict-compare d1 d2) + (and (dict? d1) (dict? d2) + (= (length d1) (length d2)) + (for/and ([(k1 v1) (in-dict d1)] + [(k2 v2) (in-dict d2)]) + (unless (equal? k1 k2) + (error (format "keys unequal: ~a ~a" k1 k2))) + (unless (equal? v1 v2) + (error (format "values unequal: ~a ~a" v1 v2))) + (when (dict? v1) + (dict-compare v1 v2)) + #true))) + (define-simple-check (check-pdfs-equal? ps1 ps2) - (equal? (pdf->dict ps1) (pdf->dict ps2))) + (dict-compare (pdf->dict ps1) (pdf->dict ps2))) #;(module+ main - (for ([p (in-directory)] - #:when (path-has-extension? p #"pdf")) - (with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))]) - (pdf->dict p)))) + (for ([p (in-directory)] + #:when (path-has-extension? p #"pdf")) + (with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))]) + (pdf->dict p)))) diff --git a/pitfall/ptest/test2.pdf b/pitfall/ptest/test2.pdf index 25c859c0..a2ebe3b1 100644 --- a/pitfall/ptest/test2.pdf +++ b/pitfall/ptest/test2.pdf @@ -119,7 +119,7 @@ endobj << /Producer (PDFKit) /Creator (PDFKit) -/CreationDate (D:20170519210839Z) +/CreationDate (D:20181120221301Z) >> endobj 2 0 obj diff --git a/pitfall/ptest/test2c.pdf b/pitfall/ptest/test2c.pdf index 4f6cc016a392c22e1cf49c516c06d7b5ede5aa28..71f1eef84a1593910dd540c386dc9ccdb23acede 100644 GIT binary patch delta 24 fcmcc2d6{#=Hb!m>Lqj72BO^m&1H;V+8HJbuVgd%* delta 24 fcmcc2d6{#=Hb!o915-mwBSQlVW6RA48HJbuV$=rm diff --git a/pitfall/ptest/test2crkt.pdf b/pitfall/ptest/test2crkt.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0859b387a4b68d0bbae4bcf95aa1cc7b9f46b8ba GIT binary patch literal 1235 zcmY!laBou;{4L0U~eB_J_9l}kS$u?VO|!4Rwi;eL>bFy96gPr66a+EOpDwDM>9-(09uL2CPeJa()WXu|BDJ=_MHo#)cLkUBx9usfoE<6?4u8 z-S#_dz*BoZ{0IAsr03W6<#|m0*1%HhV$<4bXsEKnq)z^J=H+RB8CFfQI{sYd_*y|7 z`|=afuQ)y(jZokgZ@$Ll#x2h_*P(`Mk43rZjg3ddL#9b@zFE;{CHR%?YGm2MCyzAF zB_&_o;imqqK9p6{P}{hNYtgZ-imvP{-CT83Ck6>$oa`NtXLNbvjFh$0v~m|-@H;;B zY>xi(scA)4GoK&0DZcLODe?N4n7jXfueSbSIQwtI2eTPx|9<>6uiyW-?vunfi6`by zT5kU{Ha|yr>c#hREe~5ZK7E&8XTrKJ@!^8A{+nGchsbP^J(_u}vv5_#l$lb@htv{1 zt}q_8Xq9LPnhp6EGtW&wx`V8lrY^n%MJD7 zzx`gZckXK+{e+|$c@N`j?APo9C0J-cLX)l~QY<(FL%1X}KhFgi2?`o6R)&`51_p*e z2nJD_!1Pm;pHi9(j46!(&k%3V5TFoPQ$CUiB8H8S%m$^uVrasH<|OCDlEj?+bfhE! zN|&%C;hmXMtPl;#0YNBW|Vg`ml7o&@rVcKhGfT_;h49VV- zqQuOc)FN;J6r5R=3i6wNP=0=i0w`308O$>;Enfi?d*EzUT#{H+0uBXBQwuItRabvE FE&vE1h+zN# literal 0 HcmV?d00001 diff --git a/pitfall/ptest/test2rkt.pdf b/pitfall/ptest/test2rkt.pdf new file mode 100644 index 00000000..e60937de --- /dev/null +++ b/pitfall/ptest/test2rkt.pdf @@ -0,0 +1,158 @@ +%PDF-1.3 +%ÿÿÿÿ +6 0 obj +<< +/ca 0.8 +/Type /ExtGState +>> +endobj +7 0 obj +<< +/ca 1 +/Type /ExtGState +>> +endobj +8 0 obj +<< +/CA 1 +/Type /ExtGState +>> +endobj +5 0 obj +<< +/Resources 4 0 R +/Contents 3 0 R +/MediaBox [0 0 612 792] +/Type /Page +/Parent 1 0 R +>> +endobj +4 0 obj +<< +/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] +/ExtGState << +/Gs3 8 0 R +/Gs2 7 0 R +/Gs1 6 0 R +>> +>> +endobj +3 0 obj +<< +/Length 890 +>> +stream +1 0 0 -1 0 792 cm +0 20 m +100 160 l +130 200 150 120 v +190 -40 200 200 300 150 c +400 90 l +S +1 0 0 1 0 200 cm +100 0 m +50 100 l +150 100 l +h +S +q +1 0 0 1 200 0 cm +50 50 m +50 22.385763 72.385763 0 100 0 c +127.614237 0 150 22.385763 150 50 c +150 77.614237 127.614237 100 100 100 c +72.385763 100 50 77.614237 50 50 c +h +[5 10] 0 d +S +Q +q +1 0 0 1 400 0 cm +50 50 m +50 22.385763 72.385763 0 100 0 c +127.614237 0 150 22.385763 150 50 c +150 77.614237 127.614237 100 100 100 c +72.385763 100 50 77.614237 50 50 c +h +3 w +/Gs1 gs +/DeviceRGB cs +1 0 0 scn +/Gs2 gs +/DeviceRGB CS +0.6 0 0 SCN +/Gs3 gs +B +Q +1 0 0 1 0 200 cm +25 w +0 J +50 20 m +100 20 l +S +1 J +150 20 m +200 20 l +S +2 J +250 20 m +260 30 m +260 21.715729 266.715729 15 275 15 c +283.284271 15 290 21.715729 290 30 c +290 38.284271 283.284271 45 275 45 c +266.715729 45 260 38.284271 260 30 c +h +S +0 j +50 100 50 50 re +S +1 j +150 100 50 50 re +S +2 j +250 100 50 50 re +S + +endstream +endobj +9 0 obj +<< +/CreationDate (D:19700101000000Z) +/Producer (PITKIT) +/Creator (PITKIT) +>> +endobj +2 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj +1 0 obj +<< +/Kids [5 0 R] +/Type /Pages +/Count 1 +>> +endobj +xref +0 10 +0000000000 65535 f +0000001452 00000 n +0000001403 00000 n +0000000370 00000 n +0000000253 00000 n +0000000149 00000 n +0000000015 00000 n +0000000061 00000 n +0000000105 00000 n +0000001311 00000 n +trailer +<< +/Size 10 +/Root 2 0 R +/Info 9 0 R +>> +startxref +1509 +%%EOF diff --git a/pitfall/ptest/test3.pdf b/pitfall/ptest/test3.pdf index d0cedb21..5483b25b 100644 --- a/pitfall/ptest/test3.pdf +++ b/pitfall/ptest/test3.pdf @@ -38,7 +38,7 @@ endobj << /Producer (PDFKit) /Creator (PDFKit) -/CreationDate (D:20170519210912Z) +/CreationDate (D:20181120222652Z) >> endobj 6 0 obj diff --git a/pitfall/ptest/test3c.pdf b/pitfall/ptest/test3c.pdf index f31e4c50102cefa7eade9ec5292126e6fd351dc8..e94c3b0e6164d7126ed58c96fb08ae0e67621f04 100644 GIT binary patch delta 23 ecmbQlK8byU2qTw;p`nq1k&%&^>1H{`5+(pcI|WAo delta 23 ecmbQlK8byU2qTxdfvKUTk)eU5;bu9;5+(pcjRj2r diff --git a/pitfall/ptest/test3crkt.pdf b/pitfall/ptest/test3crkt.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f0bfd39b0ffea8d605b4c956e792c3acf77ce710 GIT binary patch literal 914 zcmZWoL2DC16fTxZn6pyE%aam_2c4PhZZ@%{*lZeHqL^-03WglE$t13(GqN+$=)r@h z>dBi36+DP1FDmp0cv8HHS5KmULuWSGc5P>2hWU2hd*6KTn_|1syhJZssQ6b8U?H`wVb98Zo5j zM27%PBi7du;{%i5WX$R`by_e5n-nV9IowV}zrz%Cv1SN3WK#v$-_=R$^VOTLeh(cb zHq;Ii$7973z|C=_ScCP&Koh#o_(+kOm^+`J@_`jYX&=16NTBkqTD~nRDE_sVf=RetUW%bS0 zyQ{;Gub#bry79igxBT*6VH=hgem*%@GS{D%oD1RR_DXLV>vK{46BqipY#tu#2i-};uuyY)e{({wG$Yjn%uEi+ts2T z!>p=ybB3uTipMNTA5bTL%rs>j2%*4erQeXxhXPE~gPHxJM5TADxHVKPZr*I7e*-=J At^fc4 literal 0 HcmV?d00001 diff --git a/pitfall/ptest/test3rkt.pdf b/pitfall/ptest/test3rkt.pdf new file mode 100644 index 00000000..69d2a0d7 --- /dev/null +++ b/pitfall/ptest/test3rkt.pdf @@ -0,0 +1,83 @@ +%PDF-1.3 +%ÿÿÿÿ +5 0 obj +<< +/Resources 4 0 R +/Contents 3 0 R +/MediaBox [0 0 612 792] +/Type /Page +/Parent 1 0 R +>> +endobj +4 0 obj +<< +/Font << +/F1 6 0 R +>> +/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] +>> +endobj +3 0 obj +<< +/Length 123 +>> +stream +1 0 0 -1 0 792 cm +q +1 0 0 -1 0 792 cm +BT +1 0 0 1 72 711.384 Tm +/F1 12 Tf +[<48656c6c6f2077> 10 <6f72> -15 <6c64> 0] TJ +ET +Q + +endstream +endobj +7 0 obj +<< +/CreationDate (D:19700101000000Z) +/Producer (PITKIT) +/Creator (PITKIT) +>> +endobj +6 0 obj +<< +/Subtype /Type1 +/Encoding /WinAnsiEncoding +/BaseFont /Helvetica +/Type /Font +>> +endobj +2 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj +1 0 obj +<< +/Kids [5 0 R] +/Type /Pages +/Count 1 +>> +endobj +xref +0 8 +0000000000 65535 f +0000000620 00000 n +0000000571 00000 n +0000000208 00000 n +0000000119 00000 n +0000000015 00000 n +0000000474 00000 n +0000000382 00000 n +trailer +<< +/Size 8 +/Root 2 0 R +/Info 7 0 R +>> +startxref +677 +%%EOF