Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from tvroom/match_undef_test
Match undef test
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use Test::More qw(); | ||
#Don't import anything or test routines become potential matches during the test | ||
|
||
use Symbol::Approx::Sub ( | ||
xform => undef, | ||
match => undef | ||
); | ||
|
||
sub aa { 'aa' } | ||
|
||
sub bb { 'bb' } | ||
|
||
sub cc { 'cc' } | ||
|
||
my $total_tries = 1000; | ||
my $tries_left = $total_tries; | ||
|
||
my %remaining_returns = ( | ||
'aa' => 1, | ||
'bb' => 1, | ||
'cc' => 1, | ||
); | ||
|
||
while($tries_left >= 0) { | ||
my $ret_val = b(); | ||
delete $remaining_returns{$ret_val}; | ||
last if !keys %remaining_returns; | ||
$tries_left--; | ||
} | ||
|
||
Test::More::ok !keys %remaining_returns, "Got all expected return values (covering all our subroutines) in <= $total_tries tries"; | ||
|
||
Test::More::done_testing(); |