diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index c88b8eb6a..960e0f192 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -1013,7 +1013,9 @@ sub setRank { next; } last unless $sibling; - if (isBetween($sibling->getRank, $newRank, $currentRank)) { + my $rank = $sibling->getRank; + if ($rank >= $newRank && $rank <= $currentRank + || $rank >= $currentRank && $rank <= $newRank) { $outputSub->('moving %s', $sibling->getTitle); $sibling->cascadeLineage($previous); $previous = $sibling->lineage; diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 044ab2f91..76a79f94f 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -22,7 +22,7 @@ use Tie::IxHash; use Net::CIDR::Lite; our @ISA = qw(Exporter); -our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &randomizeArray &isInSubnet +our @EXPORT = qw(&makeTabSafe &makeArrayTabSafe &randomizeHash &randomizeArray &isInSubnet &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round &scalarEquals ); @@ -38,7 +38,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme =head1 SYNOPSIS use WebGUI::Utility; - $boolean = isBetween($value, $first, $second); $boolean = isIn($value, @array); $boolean = isInSubnet($ip, \@subnets); makeArrayCommaSafe(\@array); @@ -59,39 +58,6 @@ These subroutines are available from this package: #------------------------------------------------------------------- -=head2 isBetween ( value, first, second ) - -Returns true if value is between two other values (inclusive). Otherwise returns false. - -=head3 value - -An integer to compare against first and second. - -=head3 first - -An integer to compare value against. - -=head3 second - -Another integer to compare value against. - -=cut - -sub isBetween { - my $value = shift; - my $first = shift; - my $second = shift; - if ($first > $second) { - ($first,$second) = ($second,$first); - } - if ($value >= $first && $value <= $second) { - return 1; - } - return 0; -} - -#------------------------------------------------------------------- - =head2 isIn ( value, list ) Returns a boolean value as to whether the value is in the array. diff --git a/t/Utility.t b/t/Utility.t index 259366164..3af8b0a76 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -22,14 +22,6 @@ use Test::Deep; my $session = WebGUI::Test->session; -# isBetween -ok(WebGUI::Utility::isBetween(0,-1,1), 'isBetween() - negative and positive range'); -ok(WebGUI::Utility::isBetween(0,1,-1), 'isBetween() - negative and positive range, reversed'); -ok(WebGUI::Utility::isBetween(11,1,15), 'isBetween() - positive range'); -ok(WebGUI::Utility::isBetween(-5,-10,-2), 'isBetween() - negative range'); -ok(!WebGUI::Utility::isBetween(+5,-10,-2), 'isBetween() - not in range on high side'); -ok(!WebGUI::Utility::isBetween(-15,-10,-2), 'isBetween() - not in range on low side'); - # isIn ok(WebGUI::Utility::isIn("webgui", qw(cars trucks webgui trains)), 'isIn()');