diff options
author | Karl Williamson <khw@cpan.org> | 2014-10-16 21:00:56 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2015-03-05 21:48:27 -0700 |
commit | 9b7ae71ac101a3cc31f1bd240a7a3dd426ada2fc (patch) | |
tree | 1828e162cea0f2f7fb38568b0f855f700f139655 /ext/Hash-Util-FieldHash | |
parent | 26b21b99df35931fee21504247fd1ac98edc0493 (diff) | |
download | perl-9b7ae71ac101a3cc31f1bd240a7a3dd426ada2fc.tar.gz |
Hash-Util tests: Generalize for non-ASCII platforms
Diffstat (limited to 'ext/Hash-Util-FieldHash')
-rw-r--r-- | ext/Hash-Util-FieldHash/t/05_perlhook.t | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/Hash-Util-FieldHash/t/05_perlhook.t b/ext/Hash-Util-FieldHash/t/05_perlhook.t index 92c6b7ac4f..61d02ec646 100644 --- a/ext/Hash-Util-FieldHash/t/05_perlhook.t +++ b/ext/Hash-Util-FieldHash/t/05_perlhook.t @@ -6,6 +6,13 @@ my $n_tests; use Hash::Util::FieldHash; use Scalar::Util qw( weaken); +sub numbers_first { # Sort helper: All digit entries sort in front of others + # Makes sorting portable across ASCII/EBCDIC + return $a cmp $b if ($a =~ /^\d+$/) == ($b =~ /^\d+$/); + return -1 if $a =~ /^\d+$/; + return 1; +} + # The functions in Hash::Util::FieldHash # _test_uvar_get, _test_uvar_get and _test_uvar_both @@ -108,7 +115,7 @@ use Scalar::Util qw( weaken); $h{ def} = 456; is( $counter, 2, "lvalue assign triggers"); - (@x) = sort %h; + (@x) = sort numbers_first %h; is( $counter, 2, "hash in list context doesn't trigger"); is( "@x", "123 456 abc def", "correct result"); @@ -121,14 +128,14 @@ use Scalar::Util qw( weaken); delete $h{ def}; is( $counter, 5, "good delete triggers"); - (@x) = sort %h; + (@x) = sort numbers_first %h; is( $counter, 5, "hash in list context doesn't trigger"); is( "@x", "123 abc", "correct result"); delete $h{ xyz}; is( $counter, 6, "bad delete triggers"); - (@x) = sort %h; + (@x) = sort numbers_first %h; is( $counter, 6, "hash in list context doesn't trigger"); is( "@x", "123 abc", "correct result"); @@ -138,7 +145,7 @@ use Scalar::Util qw( weaken); $x = $h{ xyz}; is( $counter, 8, "bad read triggers"); - (@x) = sort %h; + (@x) = sort numbers_first %h; is( $counter, 8, "hash in list context doesn't trigger"); is( "@x", "123 abc", "correct result"); |