Skip to content

Commit 8ddbaa0

Browse files
committed
test some more update()/save-as() variants
1 parent cdcfd72 commit 8ddbaa0

File tree

15 files changed

+37
-19
lines changed

15 files changed

+37
-19
lines changed

coverage/PDF.rakucov

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ x False;
112112
}
113113
#| perform an incremental save back to the opened input file, or write
114114
#| differences to the specified file
115-
* method update(IO::Handle :$diffs, |c) {
115+
* method update(IO::Handle :$diffs, |c) is hidden-from-backtrace {
116116

117117
* die "Newly encrypted PDF must be saved in full"
118118
if $!flush;
@@ -162,7 +162,7 @@ x $in-place = True;
162162
}
163163
}
164164

165-
* method !incremental-save(IO::Handle:D $fh, Hash $body, :$diffs, :$in-place) {
165+
* method !incremental-save(IO::Handle:D $fh, Hash $body, :$diffs, :$in-place) is hidden-from-backtrace {
166166
my constant Pad = "\n\n".encode('latin-1');
167167

168168
✱ my Hash $trailer = $body<trailer><dict>;
@@ -203,8 +203,8 @@ x $in-place = True;
203203
* PDF::IO::Writer.new: :$ast;
204204
}
205205

206-
x multi method save-as(IO::Handle $ioh, |c) {
207-
x self!ast-writer(|c).stream-cos: $ioh;
206+
* multi method save-as(IO::Handle $ioh, |c) is hidden-from-backtrace {
207+
* self!ast-writer(|c).stream-cos: $ioh;
208208
}
209209

210210
* multi method save-as(IO() $iop,

coverage/PDF/IO/Reader.rakucov

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ x die "unable to handle indirect object update of type: $_";
307307
# ensure stream is followed by an 'endstream' marker
308308
* my Str \tail = $input.byte-str( $offset + $from + $length, $max-remaining-bytes - $length);
309309

310-
* if tail ~~ m{^<PDF::Grammar::COS::stream-tail>} {
310+
* if tail ~~ m{^<PDF::Grammar::COS::stream-tail> 'endobj'} {
311311
* warn X::PDF::BadIndirectObject.new(
312312
:$obj-num, :$gen-num, :$offset,
313313
x :details("Ignoring {$/.from} bytes before 'endstream' marker")
@@ -316,7 +316,7 @@ x :details("Ignoring {$/.from} bytes before 'endstream' marker")
316316
else {
317317
* die X::PDF::BadIndirectObject.new(
318318
:$obj-num, :$gen-num, :$offset,
319-
:details("Unable to locate 'endstream' marker after consuming /Length $length bytes")
319+
:details("Unable to locate 'endstream' 'endobj' sequence after consuming /Length $length bytes")
320320
);
321321
}
322322

coverage/PDF/IO/Writer.rakucov

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ x .rethrow();
377377
* self.stream-body: $fh, $body, my @idx, :$write-xref;
378378
}
379379

380-
x multi method stream-cos(IO::Handle:D $fh) {
381-
x $.stream-cos($fh, $!ast<cos>);
380+
* multi method stream-cos(IO::Handle:D $fh) {
381+
* $.stream-cos($fh, $!ast<cos>);
382382
}
383383

384384
* multi method stream-body(IO::Handle:D $fh, @body, |c) {

coverage/X/PDF.rakucov

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ x method message {"xref section size mismatch. Expected $!obj-count entries,
6464

6565
* class X::PDF::BadIndirectObject::Parse is X::PDF::BadIndirectObject {
6666
has Str $.input is required;
67-
* method message {
68-
* $.details = "Unable to parse indirect object: " ~ $.input.&synopsis();
69-
* nextsame;
67+
x method message {
68+
x $.details = "Unable to parse indirect object: " ~ $.input.&synopsis();
69+
x nextsame;
7070
}
7171
}
7272

lib/PDF.rakumod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ method cb-finish {
112112
}
113113
#| perform an incremental save back to the opened input file, or write
114114
#| differences to the specified file
115-
method update(IO::Handle :$diffs, |c) {
115+
method update(IO::Handle :$diffs, |c) is hidden-from-backtrace {
116116

117117
die "Newly encrypted PDF must be saved in full"
118118
if $!flush;
@@ -162,7 +162,7 @@ method update(IO::Handle :$diffs, |c) {
162162
}
163163
}
164164

165-
method !incremental-save(IO::Handle:D $fh, Hash $body, :$diffs, :$in-place) {
165+
method !incremental-save(IO::Handle:D $fh, Hash $body, :$diffs, :$in-place) is hidden-from-backtrace {
166166
my constant Pad = "\n\n".encode('latin-1');
167167

168168
my Hash $trailer = $body<trailer><dict>;
@@ -203,7 +203,7 @@ method !ast-writer(|c) {
203203
PDF::IO::Writer.new: :$ast;
204204
}
205205

206-
multi method save-as(IO::Handle $ioh, |c) {
206+
multi method save-as(IO::Handle $ioh, |c) is hidden-from-backtrace {
207207
self!ast-writer(|c).stream-cos: $ioh;
208208
}
209209

t/00-helloworld.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use v6;
22
use Test;
3-
plan 11;
3+
plan 12;
44

55
use PDF;
66
use PDF::COS::Name;
@@ -50,4 +50,5 @@ ok PDF::Grammar::PDF.parse( $pdf.Str: :compat(v1.5) ), '$pdf.Str v1.5 serializat
5050
lives-ok {$pdf .= open: $pdf.Blob}, 'reserialize from Blob';
5151
is-deeply $pdf.Info.Author, $info.Author, 'Info intact';
5252
lives-ok {$pdf.Blob}, 'second reserialization';
53+
lives-ok {$pdf.save-as("tmp/helloworld.pdf".IO.open(:w, :bin))}, 'save-as pdf IO::Handle';
5354
done-testing;

t/helloworld.pdf

0 Bytes
Binary file not shown.

t/lolcode.cjar

0 Bytes
Binary file not shown.

t/pdf/pdf-fdf.out

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
%FDF-1.2
2+
%���
3+
1 0 obj
4+
<<
5+
/FDF <<
6+
/F (Document.pdf)
7+
/Fields [ << /T (Street) /V (345 Park Ave.) >> << /T (City) /V (San Jose) >> ]
8+
/ID [ <7a0631678ed475f0898815f0a818cfa1> <bef7724317b311718e8675b677ef9b4e> ]
9+
>>
10+
>>
11+
endobj
12+
13+
trailer
14+
<< /Root 1 0 R >>
15+
%%EOF

t/pdf/pdf-updated-and-rebuilt.pdf

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)