Skip to content

Commit

Permalink
Use direct object syntax for calls to new in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Cochrane committed Jun 26, 2016
1 parent 4e093f8 commit 5e1e073
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions t/basic.t
Expand Up @@ -8,7 +8,7 @@ use Time::HiRes qw/sleep time/;

BEGIN { use_ok('Algorithm::TokenBucket'); }

my $bucket = new Algorithm::TokenBucket 25/1, 4;
my $bucket = Algorithm::TokenBucket->new(25/1, 4);
isa_ok($bucket, 'Algorithm::TokenBucket');
is($bucket->{info_rate}, 25, 'info_rate init');
is($bucket->{burst_size}, 4, 'burst_size init');
Expand Down Expand Up @@ -54,15 +54,15 @@ while (time - $time < 2) {
}
cmp_ok($traffic, '>=', 0, '50 or less in 2 seconds');

$bucket = new Algorithm::TokenBucket 25/1, 4; # start afresh (point C)
$bucket = Algorithm::TokenBucket->new(25/1, 4); # start afresh (point C)

my @state = $bucket->state;
is($state[0], 25, 'state[0]');
is($state[1], 4, 'state[1]');
cmp_ok($state[2], '<', 0.01, 'state[2]');
cmp_ok(abs($state[3] - time), '<', 0.1, 'state[3]');

my $bucket1 = new Algorithm::TokenBucket @state;
my $bucket1 = Algorithm::TokenBucket->new(@state);
isa_ok($bucket1, 'Algorithm::TokenBucket');
ok(!$bucket1->conform(2), 'restored bucket is almost empty'); # point D
# if it took us long (>1/25 sec) from point C up to point D, conform(1) could be true
Expand Down

0 comments on commit 5e1e073

Please sign in to comment.