Add some basic tests for sortHash and sortHashDescending to the
test suite for WebGUI::Utility.
This commit is contained in:
parent
282e1caacd
commit
7ea06b9a81
1 changed files with 21 additions and 10 deletions
31
t/Utility.t
31
t/Utility.t
|
|
@ -74,14 +74,25 @@ SKIP: {
|
||||||
is(WebGUI::Utility::round(47.133984233, 0), 47, 'round() - 0 significant digits');
|
is(WebGUI::Utility::round(47.133984233, 0), 47, 'round() - 0 significant digits');
|
||||||
is(WebGUI::Utility::round(47.133984233, 3), 47.134, 'round() - multiple significant digits');
|
is(WebGUI::Utility::round(47.133984233, 3), 47.134, 'round() - multiple significant digits');
|
||||||
|
|
||||||
# sortHash
|
{
|
||||||
SKIP: {
|
# Just some basic tests for now.
|
||||||
skip("Don't know how to test sortHash.",1);
|
|
||||||
ok(undef, 'sortHash()');
|
|
||||||
}
|
|
||||||
|
|
||||||
# sortHashDescending
|
# XXX: These both fail. I think whoever designed sortHash and
|
||||||
SKIP: {
|
# sortHashDescending didn't know how Perl calling conventions
|
||||||
skip("Don't know how to test sortHashDescending.",1);
|
# work---the Tie::IxHash association, and therefore the order
|
||||||
ok(undef, 'sortHashDescending()');
|
# preservation, goes away as soon as you unbox the hash... it
|
||||||
}
|
# probably works if you tie the hash on the caller's end
|
||||||
|
# first, but that's not how I interpret the documentation as
|
||||||
|
# specifying it. --DPW
|
||||||
|
|
||||||
|
my (%hash1, %hash2, %hash3);
|
||||||
|
%hash1 = ('a' => 5, 'b' => 3, 'c' => 2, 'd' => 4, 'e' => 1);
|
||||||
|
%hash2 = WebGUI::Utility::sortHash(%hash1);
|
||||||
|
%hash3 = WebGUI::Utility::sortHashDescending(%hash1);
|
||||||
|
is_deeply([keys %hash2], [qw/e c b d a/], 'sortHash');
|
||||||
|
is_deeply([keys %hash3], [qw/a d b c e/], 'sortHashDescending');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# mode: cperl
|
||||||
|
# End:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue