diff options
Diffstat (limited to 'gnu/usr.bin/perl/ext/B/t')
-rw-r--r-- | gnu/usr.bin/perl/ext/B/t/bool.t | 59 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/B/t/walkoptree.t | 6 |
2 files changed, 64 insertions, 1 deletions
diff --git a/gnu/usr.bin/perl/ext/B/t/bool.t b/gnu/usr.bin/perl/ext/B/t/bool.t new file mode 100644 index 00000000000..1af7dfbab0e --- /dev/null +++ b/gnu/usr.bin/perl/ext/B/t/bool.t @@ -0,0 +1,59 @@ +#!./perl + +BEGIN { + unshift @INC, 't'; + require Config; + if (($Config::Config{'extensions'} !~ /\bB\b/) ){ + print "1..0 # Skip -- Perl configured without B module\n"; + exit 0; + } +} + +use strict; +use warnings; + +use B; +use Test::More; + +$| = 1; + +{ + note "testing true"; + my $bool = ( 1 == 1 ); + my $sv = B::svref_2object(\$bool); + ok $sv->IsBOOL, "got a boolean"; + ok $sv->TRUE_nomg, "TRUE_nomg is true"; + ok $sv->TRUE, "TRUE is true"; +} + +{ + note "testing false"; + my $bool = ( 1 == 0 ); + my $sv = B::svref_2object(\$bool); + + ok $sv->IsBOOL, "got a boolean"; + ok !$sv->TRUE_nomg, "TRUE_nomg is false"; + ok !$sv->TRUE, "TRUE is false"; +} + +{ + note "not a boolean"; + my $iv = 42; + my $sv = B::svref_2object(\$iv); + + ok !$sv->IsBOOL, "not a boolean"; + ok $sv->TRUE_nomg, "TRUE_nomg is true"; + ok $sv->TRUE, "TRUE is true"; +} + +{ + note "not a boolean"; + my $iv = 0; + my $sv = B::svref_2object(\$iv); + + ok !$sv->IsBOOL, "not a boolean"; + ok !$sv->TRUE_nomg, "TRUE_nomg is false"; + ok !$sv->TRUE, "TRUE is false"; +} + +done_testing(); diff --git a/gnu/usr.bin/perl/ext/B/t/walkoptree.t b/gnu/usr.bin/perl/ext/B/t/walkoptree.t index e7a39b16244..29aaf47409e 100644 --- a/gnu/usr.bin/perl/ext/B/t/walkoptree.t +++ b/gnu/usr.bin/perl/ext/B/t/walkoptree.t @@ -48,7 +48,11 @@ foreach (qw(substcont split leavesub)) { is_deeply ([keys %debug], [], 'walkoptree_debug was not called'); B::walkoptree_debug(2); -is (B::walkoptree_debug, 1, 'walkoptree_debug() is 1'); +is (B::walkoptree_debug(), 1, 'walkoptree_debug() is 1'); +B::walkoptree_debug(0); +is (B::walkoptree_debug(), 0, 'walkoptree_debug() is 0'); +B::walkoptree_debug(1); +is (B::walkoptree_debug(), 1, 'walkoptree_debug() is 1 again'); %seen = (); B::walkoptree(B::svref_2object($victim)->ROOT, "pie"); |