1 # (X)Emacs mode: -*- cperl -*-
7 =head1 Unit Test Package for Term::ProgressBar
9 This package tests the basic functionality of Term::ProgressBar.
13 use Test::More tests => 8;
16 use Capture::Tiny qw(capture_stderr);
18 my $MESSAGE1 = 'Walking on the Milky Way';
20 # -------------------------------------
24 Create a progress bar with 10 things.
25 Update it it from 1 to 10. Verify that it has no output.
29 my $err = capture_stderr {
31 lives_ok { $p = Term::ProgressBar->new({ count => 10, silent => 1}); } 'Count 1-10 (1)';
32 lives_ok { $p->update($_) for 1..5 } 'Count 1-10 (2)';
33 lives_ok { $p->message($MESSAGE1) } 'Count 1-10 (3)';
34 lives_ok { $p->update($_) for 6..10 } 'Count 1-10 (4)';
37 diag "ERR:\n$err\nlength: " . length($err)
39 ok !$err, 'We should have no output';
42 # -------------------------------------
44 =head2 Tests 9--11: Message Check
46 Run a progress bar from 0 to 100, each time calling a message after an update.
47 Check that we still have no output.
52 my $err = capture_stderr {
54 lives_ok { $p = Term::ProgressBar->new({ count => 100, silent => 1}); } 'Message Check ( 1)';
55 lives_ok { for (0..100) { $p->update($_); $p->message("Hello") } } 'Message Check ( 2)';
58 ok !$err, 'We should sill have no output';
61 # ----------------------------------------------------------------------------