File: basic.t

package info (click to toggle)
libterm-progressbar-simple-perl 0.03-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 72 kB
  • sloc: perl: 91; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (3)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl -w

use strict;
use warnings;

use lib 'lib';

use Test::More tests => 5;

use Term::ProgressBar::Simple;
use Time::HiRes qw( sleep );

{
    diag "Testing simple ++ increment";

    my $progress = Term::ProgressBar::Simple->new(10_000);

    for ( 1 .. 10000 ) {
        $progress++;
    }

    pass 'tested ++';
}

{
    diag "Testing ++ increment with early exit";

    my $progress = Term::ProgressBar::Simple->new(10_000);

    for ( 1 .. 10000 ) {
        $progress++;
    }

}
pass 'tested ++ with early exit';

{
    diag "Testing += increment";

    my @squares = map { $_**2 } 1 .. 20;

    my $total = 0;
    $total += $_ for @squares;

    my $progress = Term::ProgressBar::Simple->new($total);

    for (@squares) {
        sleep 0.2;
        $progress += $_;
    }

    pass 'tested +=';
}

{
    diag "Testing message";

    my $progress = Term::ProgressBar::Simple->new(2);
    $progress->message('At the beginning');
    $progress++;
    $progress->message('At the middle');
    $progress++;
    $progress->message('At the end');
    pass 'tested message';
}

pass "made it to end of code";