diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 9eef28353..86a649224 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -125,9 +125,7 @@ sub isBetween { my $first = shift; my $second = shift; if ($first > $second) { - my $temp = $first; - $first = $second; - $second = $temp; + ($first,$second) = ($second,$first); } if ($value >= $first && $value <= $second) { return 1; diff --git a/t/Utility.t b/t/Utility.t index 545f307a8..b10734728 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -33,6 +33,7 @@ is(WebGUI::Utility::formatBytes(1700000), '2 MB', 'formatBytes() - megabytes'); # 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');