X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-args.t;h=c16a1c5ec638a999d0956d10ec5c2080aff373c3;hb=HEAD;hp=60dd70fe0cf8fb8dc00eb3fc86d283ba7c582909;hpb=0b3c9376d654b86126708b9d63c873df6ed22811;p=perl%2Fmodules%2FB-RecDeparse.git diff --git a/t/11-args.t b/t/11-args.t index 60dd70f..c16a1c5 100644 --- a/t/11-args.t +++ b/t/11-args.t @@ -8,22 +8,29 @@ use Test::More tests => 4 * 4 + 4 * 2; use B::Deparse; use B::RecDeparse; +my $bd_version = $B::Deparse::VERSION; +{ + local $@; + $bd_version = eval $bd_version; + die $@ if $@; +} + sub add ($$) { $_[0] + $_[1] } sub mul { $_[0] * $_[1] } sub fma { add mul($_[0], $_[1]), $_[2] } sub wut { fma $_[0], 2, $_[1] } -my @br_args = ('', '-sCi0v1'); +my @bd_args = ('', '-sCi0v1'); my @brd_args = ({ }, { deparse => undef }, { deparse => { } }, { deparse => [ ] }); -my $br = B::Deparse->new(); -my $reference = $br->coderef2text(\&wut); +my $bd = B::Deparse->new(); +my $reference = $bd->coderef2text(\&wut); my $i = 1; for (@brd_args) { my $brd = B::RecDeparse->new(%$_, level => 0); my $code = $brd->coderef2text(\&wut); SKIP: { - skip 'Harmless mismatch on "use warnings" code generation with olders B::Deparse' => 1 if $B::Deparse::VERSION < 0.71; + skip 'Harmless mismatch on "use warnings" code generation with olders B::Deparse' => 1 if $bd_version < 0.71; is($code, $reference, "empty deparse and level 0 does the same thing as B::Deparse ($i)"); } $code = eval 'sub ' . $code; @@ -33,13 +40,13 @@ SKIP: { ++$i; } -my $br_opts = '-sCi0v1'; -@brd_args = ({ deparse => $br_opts }, { deparse => [ $br_opts ] }); +my $bd_opts = '-sCi0v1'; +@brd_args = ({ deparse => $bd_opts }, { deparse => [ $bd_opts ] }); for (@brd_args) { - $br = B::Deparse->new($br_opts); + $bd = B::Deparse->new($bd_opts); my $brd = B::RecDeparse->new(%$_, level => 0); my $code = $brd->coderef2text(\&wut); - is($code, $br->coderef2text(\&wut), "B::RecDeparse->new(deparse => '$br_opts' ), level => 0) does the same thing as B::Deparse->new('$br_opts') ($i)"); + is($code, $bd->coderef2text(\&wut), "B::RecDeparse->new(deparse => '$bd_opts' ), level => 0) does the same thing as B::Deparse->new('$bd_opts') ($i)"); $code = eval 'sub ' . $code; is($@, '', "result compiles ($i)"); is_deeply( [ defined $code, ref $code ], [ 1, 'CODE' ], "result compiles to a code reference ($i)");