X-Git-Url: https://git.donarmstrong.com/?p=term-progressbar.git;a=blobdiff_plain;f=t%2Fcompat.t;fp=t%2Fcompat.t;h=8f71b1891d66dc3ef0cb7bf2615e7315920e768e;hp=19855a0b74b26f36a5e8790b00f2ba08afe5c17b;hb=2256bba0170029adbe6ce865c0b7c3edbededfe7;hpb=ee92123a8fb2bca08dba2132e5ff39404e2b7703 diff --git a/t/compat.t b/t/compat.t index 19855a0..8f71b18 100644 --- a/t/compat.t +++ b/t/compat.t @@ -29,39 +29,29 @@ my $test_str = 'test'; my $tp; { my ($out, $err) = capture { $tp = Term::ProgressBar->new($test_str, $count); }; - ok $tp; - is $out, ''; + isa_ok $tp, 'Term::ProgressBar'; + is $out, '', 'empty stdout'; is $err, "$test_str: "; } -# print Data::Dumper->Dump([$b, $out, $err], [qw( b o e)]) -# if $ENV{TEST_DEBUG}; - diag 'do half the stuff and check half the bar has printed'; my $halfway = floor($count / 2); { - my ($out, $err) = capture { update $tp foreach (0 .. $halfway - 1) }; - is $out, ''; + my ($out, $err) = capture { $tp->update foreach (0 .. $halfway - 1) }; + is $out, '', 'empty stdout'; is $err, ('#' x floor(50 / 2)); - -# print Data::Dumper->Dump([$o], [qw( o )]) -# if $ENV{TEST_DEBUG}; } # do the rest of the stuff and check the whole bar has printed { - my ($out, $err) = capture { update $tp foreach ($halfway .. $count - 1) }; - is $out, ''; + my ($out, $err) = capture { $tp->update foreach ($halfway .. $count - 1) }; + is $out, '', 'empty stdout'; is $err, ('#' x ceil(50 / 2)) . "\n"; -# print Data::Dumper->Dump([$o], [qw( o )]) -# if $ENV{TEST_DEBUG}; - } # try to do another item and check there is an error -eval { update $tp }; -ok defined($@); -is substr($@, 0, length(Term::ProgressBar::ALREADY_FINISHED)), +eval { $tp->update }; +my $err = $@; +ok defined($err); +is substr($err, 0, length(Term::ProgressBar::ALREADY_FINISHED)), Term::ProgressBar::ALREADY_FINISHED; -# print Data::Dumper->Dump([$@], [qw( @ )]) -# if $ENV{TEST_DEBUG};