Skip to content

Commit

Permalink
Add tests for deprecated openpage, importpage, and openScalar
Browse files Browse the repository at this point in the history
  • Loading branch information
ssimms committed Apr 13, 2021
1 parent 234e5b3 commit a10b770
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion t/deprecations.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 1;
use Test::More tests => 4;

use strict;
use warnings;
Expand All @@ -12,3 +12,29 @@ my $pdf = PDF::API2->new();
my $image = PDF::API2::Resource::XObject::Image::JPEG->new_api($pdf, 't/resources/1x1.jpg');

ok($image, q{new_api still works});


##
## PDF::API2
##

$pdf = PDF::API2->new();
$pdf->page->gfx->fillcolor('blue');
my $pdf_string = $pdf->stringify();

# openScalar
$pdf = PDF::API2->openScalar($pdf_string);
is(ref($pdf), 'PDF::API2',
q{openScalar still works});

# importpage
my $pdf2 = PDF::API2->new();
my $page = $pdf2->importpage($pdf, 1);
is(ref($page), 'PDF::API2::Page',
q{importpage still works});

# openpage
$pdf2 = PDF::API2->open_scalar($pdf_string);
$page = $pdf->openpage(1);
is(ref($page), 'PDF::API2::Page',
q{openpage still works});

1 comment on commit a10b770

@PhilterPaper
Copy link

@PhilterPaper PhilterPaper commented on a10b770 Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to think about killing two birds with one stone, by also testing the newly-added interface at the same time. For example,

# openScalar
$pdf = PDF::API2->openScalar($pdf_string);
is(ref($pdf), 'PDF::API2',
   q{openScalar still works});
$pdf = PDF::API2->open_scalar($pdf_string);
is(ref($pdf), 'PDF::API2',
   q{new open_scalar works});

Of course, that leaves open the question of where to "permanently" test open_scalar when and if you remove the deprecated openScalar some time in the future! You may wish to add the test for open_scalar somewhere else.

Please sign in to comment.