diff options
author | Yves Orton <demerphq@gmail.com> | 2012-08-27 08:54:50 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2012-11-08 08:10:17 +0100 |
commit | 91d419acae8f9fecd22ae9054297725fbddda0a2 (patch) | |
tree | 3422d2da9af3b2aa567e1982137eaf42e17e7935 /cpan/autodie/t/hints_pod_examples.t | |
parent | e7eb9d6b8a020c216e2fe51ba09dd7561a729258 (diff) | |
download | perl-91d419acae8f9fecd22ae9054297725fbddda0a2.tar.gz |
fix a hash key order dependency in cpan/autodie/t/hints_pod_examples.t
At the same time make part of the internals deterministic Just In Case.
Version bump on autodie to 2.13 as well.
Diffstat (limited to 'cpan/autodie/t/hints_pod_examples.t')
-rw-r--r-- | cpan/autodie/t/hints_pod_examples.t | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/cpan/autodie/t/hints_pod_examples.t b/cpan/autodie/t/hints_pod_examples.t index a3c6f0f553..21a85fd474 100644 --- a/cpan/autodie/t/hints_pod_examples.t +++ b/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; |