summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/ext/B/t/bool.t
diff options
context:
space:
mode:
authorAndrew Fresh <afresh1@cvs.openbsd.org>2024-05-14 19:36:43 +0000
committerAndrew Fresh <afresh1@cvs.openbsd.org>2024-05-14 19:36:43 +0000
commit0aa19f5e10f3aa68dc15f265cb9e764af0950d32 (patch)
tree94c5ea412c688c4d44226904fabaa10a40e30588 /gnu/usr.bin/perl/ext/B/t/bool.t
parentde628b3172c196b4c8e91f4e9d554f4ade647bf0 (diff)
Import perl-5.38.2
ok gkoehler@ Commit and we'll fix fallout bluhm@ Right away, please deraadt@
Diffstat (limited to 'gnu/usr.bin/perl/ext/B/t/bool.t')
-rw-r--r--gnu/usr.bin/perl/ext/B/t/bool.t59
1 files changed, 59 insertions, 0 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();