From cb938487cbacf588d7760e37930d02aa81519c0d Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 20 Aug 2010 12:58:50 -0500 Subject: [PATCH] remove WebGUI::Utility::randint --- lib/WebGUI/Session/Url.pm | 2 +- lib/WebGUI/Utility.pm | 27 +-------------------------- t/Utility.t | 8 -------- 3 files changed, 2 insertions(+), 35 deletions(-) diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index 26fee7b9c..cc8fac68d 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -182,7 +182,7 @@ sub gateway { my $url = $self->make_urlmap_work($self->session->config->get("gateway")).'/'.$pageUrl; $url =~ s/\/+/\//g; if ($self->session->setting->get("preventProxyCache") == 1 and !$skipPreventProxyCache) { - $url = $self->append($url,"noCache=".randint(0,1000).':'.time()); + $url = $self->append($url,"noCache=".int(rand(1001)).':'.time()); } if ($pairs) { $url = $self->append($url,$pairs); diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 5efd1ff0a..a3936109e 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -23,7 +23,7 @@ use Net::CIDR::Lite; our @ISA = qw(Exporter); our @EXPORT = qw(&isInSubnet - &sortHash &isIn &randint &round + &sortHash &isIn &round ); @@ -40,7 +40,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme use WebGUI::Utility; $boolean = isIn($value, @array); $boolean = isInSubnet($ip, \@subnets); - $integer = randint($low,$high); $rounded = round($number, $digits); %hash = sortHash(%hash); @@ -117,30 +116,6 @@ sub isInSubnet { #------------------------------------------------------------------- -=head2 randint ( low, high ) - -Returns an integer between the low and high number. - -=head3 low - -The lowest possible value. Defaults to 0. - -=head3 high - -The highest possible value. Defaults to 1. - -=cut - -sub randint { - my ($low, $high) = @_; - $low = 0 unless defined $low; - $high = 1 unless defined $high; - ($low, $high) = ($high,$low) if $low > $high; - return $low + int( rand( $high - $low + 1 ) ); -} - -#------------------------------------------------------------------- - =head2 round ( float [, significantDigits ] ) Returns an integer after rounding a floating point number. diff --git a/t/Utility.t b/t/Utility.t index 39bf6aa39..79893bfba 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -26,14 +26,6 @@ my $session = WebGUI::Test->session; ok(WebGUI::Utility::isIn("webgui", qw(cars trucks webgui trains)), 'isIn()'); -# randint -my $number = WebGUI::Utility::randint(50,75); -ok($number >= 50 && $number <= 75, 'randint()'); -$number = WebGUI::Utility::randint(); -ok($number >= 0 && $number <= 1, 'randint() with default params'); -my $number = WebGUI::Utility::randint(10,5); -ok($number >= 5 && $number <= 10, 'randint() auto reverses params if they are backwards'); - # round 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');