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
20 changed files
with
291 additions
and
30 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,38 @@ | ||
#!./perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Config (); | ||
use Scalar::Util (); | ||
use Test::More | ||
(grep { /isbool/ } @Scalar::Util::EXPORT_FAIL) ? (skip_all => 'isbool is not supported on this perl') : | ||
(!$Config::Config{usethreads}) ? (skip_all => 'perl does not support threads') : | ||
(tests => 5); | ||
|
||
use threads; | ||
use threads::shared; | ||
|
||
Scalar::Util->import("isbool"); | ||
|
||
ok(threads->create( sub { isbool($_[0]) }, !!0 )->join, | ||
'value in to thread is bool'); | ||
|
||
ok(isbool(threads->create( sub { return !!0 } )->join), | ||
'value out of thread is bool'); | ||
|
||
{ | ||
my $var = !!0; | ||
ok(threads->create( sub { isbool($var) } )->join, | ||
'variable captured by thread is bool'); | ||
} | ||
|
||
{ | ||
my $sharedvar :shared = !!0; | ||
|
||
ok(isbool($sharedvar), | ||
':shared variable is bool outside'); | ||
|
||
ok(threads->create( sub { isbool($sharedvar) } )->join, | ||
':shared variable is bool inside thread'); | ||
} |
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,64 @@ | ||
#!./perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Scalar::Util (); | ||
use Test::More (grep { /isbool/ } @Scalar::Util::EXPORT_FAIL) | ||
? (skip_all => 'isbool is not supported on this perl') | ||
: (tests => 15); | ||
|
||
Scalar::Util->import("isbool"); | ||
|
||
# basic constants | ||
{ | ||
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'); | ||
} | ||
|
||
# variables | ||
{ | ||
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'); | ||
} | ||
|
||
# aggregate members | ||
{ | ||
my %hash = ( false => !!0, true => !!1 ); | ||
|
||
ok(isbool($hash{false}), 'false HELEM is boolean'); | ||
ok(isbool($hash{true}), 'true HELEM is boolean'); | ||
|
||
# We won't test AELEM but it's likely to be the same | ||
} | ||
|
||
{ | ||
my $var; | ||
package Foo { sub TIESCALAR { bless {}, shift } sub FETCH { $var } } | ||
|
||
tie my $tied, "Foo"; | ||
|
||
$var = 1; | ||
ok(!isbool($tied), 'tied var should not yet be boolean'); | ||
|
||
$var = !!1; | ||
ok(isbool($tied), 'tied var should now be boolean'); | ||
|
||
my $copy = $tied; | ||
ok(isbool($copy), 'copy of tied var should also be boolean'); | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package attributes; | ||
|
||
our $VERSION = 0.33; | ||
our $VERSION = 0.34; | ||
|
||
@EXPORT_OK = qw(get reftype); | ||
@EXPORT = (); | ||
|
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
Oops, something went wrong.