Skip to content

Commit

Permalink
Data-Dumper: fix deparse.t for non-XS testing
Browse files Browse the repository at this point in the history
This is a follow-up to b5048e7, which
added 'Deparse' support to XS and made both XS and pure Perl testing
mandatory. The other test files treat XS as optional, so this patch
follows that pattern. (If we decide that the XS part of Data::Dumper is
not optional, we should change all the other test files for
consistency.)

Previously, testing without XS available resulted in:

    t/deparse.t ................... Undefined subroutine &Data::Dumper::Dumpxs called at .../dist/Data-Dumper/blib/lib/Data/Dumper.pm line 213.
    # Looks like your test exited with 255 before it could output anything.
    t/deparse.t ................... Dubious, test returned 255 (wstat 65280, 0xff00)
    Failed 16/16 subtests
    ...
    t/deparse.t                 (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
      Non-zero exit status: 255
      Parse errors: Bad plan.  You planned 16 tests but ran 0.
  • Loading branch information
mauke committed Jan 9, 2025
1 parent f8cc94d commit c135673
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dist/Data-Dumper/t/deparse.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;

use Data::Dumper;
use Test::More tests => 16;
use Test::More tests => 16;
use lib qw( ./t/lib );
use Testing qw( _dumptostr );

Expand All @@ -14,11 +14,18 @@ use Testing qw( _dumptostr );

note("\$Data::Dumper::Deparse and Deparse()");

for my $useperl (0, 1) {
local $Data::Dumper::Useperl = $useperl;
run_tests_for_deparse();
SKIP: {
skip "XS version was unavailable, so we already ran with pure Perl", 8
if $Data::Dumper::Useperl;
local $Data::Dumper::Useperl = 1;
run_tests_for_deparse();
}

sub run_tests_for_deparse {
my $useperl = $Data::Dumper::Useperl ? 1 : 0;

my ($obj, %dumps, $deparse, $starting);
use strict;
my $struct = { foo => "bar\nbaz", quux => sub { "fleem" } };
$obj = Data::Dumper->new( [ $struct ] );
$dumps{'noprev'} = _dumptostr($obj);
Expand Down

0 comments on commit c135673

Please sign in to comment.