Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!./perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Scalar::Util (); | ||
use Test::More (grep { /isbool/ } @Scalar::Util::EXPORT_FAIL) | ||
? (skip_all => 'isbool requires XS version') | ||
: (tests => 12); | ||
|
||
Scalar::Util->import("isbool"); | ||
|
||
ok(isbool(!!0), 'false is boolean'); | ||
ok(isbool(!!1), 'true is boolean'); | ||
|
||
ok(!isbool(0), '0 is not boolean'); | ||
ok(!isbool(1), '1 is not boolean'); | ||
ok(!isbool(""), '"" is not boolean'); | ||
|
||
my $falsevar = !!0; | ||
my $truevar = !!1; | ||
|
||
ok(isbool($falsevar), 'false var is boolean'); | ||
ok(isbool($truevar), 'true var is boolean'); | ||
|
||
my $str = "$truevar"; | ||
my $num = $truevar + 0; | ||
|
||
ok(!isbool($str), 'stringified true is not boolean'); | ||
ok(!isbool($num), 'numified true is not boolean'); | ||
|
||
ok(isbool($truevar), 'true var remains boolean after stringification and numification'); | ||
|
||
my %hash = ( false => !!0, true => !!1 ); | ||
|
||
ok(isbool($hash{false}), 'false HELEM is boolean'); | ||
ok(isbool($hash{true}), 'true HELEM is boolean'); |