1 # (X)Emacs mode: -*- cperl -*-
5 =head1 Unit Test Package for Term::ProgressBar
7 This package tests the zero-progress handling of progress bar.
11 use Data::Dumper qw( Dumper );
12 use FindBin qw( $Bin );
13 use Test qw( ok plan );
15 use Capture::Tiny qw(capture);
18 use test qw( evcheck );
21 # 1 for compilation test,
26 =head2 Test 1: compilation
28 This test confirms that the test script and the modules it calls compiled
33 use Term::ProgressBar;
35 ok 1, 1, 'compilation';
37 Term::ProgressBar->__force_term (50);
39 # -------------------------------------
41 =head2 Tests 2--5: V1 mode
43 Create a progress bar with 0 things.
44 Update it it from 1 to 10.
46 (1) Check no exception thrown on creation
47 (2) Check no exception thrown on update
48 (3) Check bar displays name
49 (3) Check bar says nothing to do
56 my ($out, $err) = capture {
57 $name = 'doing nothing';
58 ok (evcheck(sub { $p = Term::ProgressBar->new($name, 0); },
61 ok (evcheck(sub { $p->update($_) for 1..10 },'V1 mode ( 2)'),
65 my @lines = grep $_ ne '', split /\r/, $err;
68 ok $lines[-1], qr/^$name:/, 'V1 mode ( 3)';
69 ok $lines[-1], qr/\(nothing to do\)/, 'V1 mode ( 4)';
72 # -------------------------------------
74 =head2 Tests 6--9: V2 mode
76 Create a progress bar with 0 things.
77 Update it it from 1 to 10.
79 (1) Check no exception thrown on creation
80 (2) Check no exception thrown on update
81 (3) Check bar displays name
82 (4) Check bar says nothing to do
89 my ($out, $err) = capture {
90 ok (evcheck(sub { $p = Term::ProgressBar->new({ count => 0,
94 ok (evcheck(sub { $p->update($_) for 1..10 },'V2 mode ( 2)'),
98 my @lines = grep $_ ne '', split /\r/, $err;
101 ok $lines[-1], qr/^$name:/, 'V2 mode ( 3)';
102 ok $lines[-1], qr/\(nothing to do\)/, 'V2 mode ( 4)';
105 # ----------------------------------------------------------------------------