File: constant.t

package info (click to toggle)
libalgorithm-backoff-perl 0.010-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: perl: 880; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!perl

use strict;
use warnings;
use Test::More 0.98;
use Test::Number::Delta within => 1e-3;

use Algorithm::Backoff::Constant;

#subtest "required arguments" => sub {
#};

subtest "basics" => sub {
    my $ar = Algorithm::Backoff::Constant->new(
        delay            => 2,
        delay_on_success => 1,
    );

    is($ar->success(1), 1);
    is($ar->success(1), 1);
    is($ar->failure(1), 2);
    is($ar->failure(1), 2);
    is($ar->failure(2), 2); # test consider_actual_delay = 0
    is($ar->failure(4), 2); # test consider_actual_delay = 0

    # test using real timestamps
    $ar = Algorithm::Backoff::Constant->new(
        delay            => 2,
        delay_on_success => 1,
    );
    delta_ok($ar->success, 1);
    delta_ok($ar->failure, 2);
};

# XXX test jitters

DONE_TESTING:
done_testing;