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::More tests => 9;
15 use Capture::Tiny qw(capture);
18 use test qw( evcheck );
20 use_ok 'Term::ProgressBar';
22 Term::ProgressBar->__force_term (50);
24 # -------------------------------------
26 =head2 Tests 2--5: V1 mode
28 Create a progress bar with 0 things.
29 Update it it from 1 to 10.
31 (1) Check no exception thrown on creation
32 (2) Check no exception thrown on update
33 (3) Check bar displays name
34 (3) Check bar says nothing to do
41 my ($out, $err) = capture {
42 $name = 'doing nothing';
43 ok (evcheck(sub { $p = Term::ProgressBar->new($name, 0); },
46 ok (evcheck(sub { $p->update($_) for 1..10 },'V1 mode ( 2)'),
50 my @lines = grep $_ ne '', split /\r/, $err;
53 like $lines[-1], qr/^$name:/, 'V1 mode ( 3)';
54 like $lines[-1], qr/\(nothing to do\)/, 'V1 mode ( 4)';
57 # -------------------------------------
59 =head2 Tests 6--9: V2 mode
61 Create a progress bar with 0 things.
62 Update it it from 1 to 10.
64 (1) Check no exception thrown on creation
65 (2) Check no exception thrown on update
66 (3) Check bar displays name
67 (4) Check bar says nothing to do
74 my ($out, $err) = capture {
75 ok (evcheck(sub { $p = Term::ProgressBar->new({ count => 0,
79 ok (evcheck(sub { $p->update($_) for 1..10 },'V2 mode ( 2)'),
83 my @lines = grep $_ ne '', split /\r/, $err;
86 like $lines[-1], qr/^$name:/, 'V2 mode ( 3)';
87 like $lines[-1], qr/\(nothing to do\)/, 'V2 mode ( 4)';
90 # ----------------------------------------------------------------------------