diff options
Diffstat (limited to 'gnu/usr.bin/perl/cpan/autodie/t/hints_pod_examples.t')
-rwxr-xr-x | gnu/usr.bin/perl/cpan/autodie/t/hints_pod_examples.t | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/gnu/usr.bin/perl/cpan/autodie/t/hints_pod_examples.t b/gnu/usr.bin/perl/cpan/autodie/t/hints_pod_examples.t index a3c6f0f5538..21a85fd474d 100755 --- a/gnu/usr.bin/perl/cpan/autodie/t/hints_pod_examples.t +++ b/gnu/usr.bin/perl/cpan/autodie/t/hints_pod_examples.t @@ -152,22 +152,43 @@ my $perl58_fix = ( ); # Some of the tests provide different hints for scalar or list context - -while (my ($test, $exception_expected) = each %scalar_tests) { - eval " +# NOTE: these tests are sensitive to order (not sure why) therefore +# this loop must use a sorted list of keys . Otherwise there is an occasional +# failure like this: +# +# Failed test 'scalar test - zero_scalar("")' +# at cpan/autodie/t/hints_pod_examples.t line 168. +# got: 'Can't zero_scalar(''): at cpan/autodie/t/hints_pod_examples.t line 157 +# ' +# expected: '' +# +# +# my $scalar = zero_scalar(""); +# 1; + + +foreach my $test (sort keys %scalar_tests) { + my $exception_expected= $scalar_tests{$test}; + my $ok= eval(my $code= " $perl58_fix my \$scalar = $test; - "; + 1; + "); if ($exception_expected) { - isnt("$@", "", "scalar test - $test"); + isnt($ok ? "" : "$@", "", "scalar test - $test") + or diag($code); } else { - is($@, "", "scalar test - $test"); + is($ok ? "" : "$@", "", "scalar test - $test") + or diag($code); } } -while (my ($test, $exception_expected) = each %list_tests) { + +# this set of test is not *known* to be order dependent however we sort it anyway out caution +foreach my $test (sort keys %list_tests) { + my $exception_expected= $list_tests{$test}; eval " $perl58_fix my \@array = $test; |