X-Git-Url: https://git.donarmstrong.com/?p=term-progressbar.git;a=blobdiff_plain;f=t%2Fv2-mobile.t;h=342d06ffb11f52f7eec223735df3fe3316803957;hp=5176a52b8cfec437274dcd3f6ffec49793c36130;hb=c3f8be419c0674c8a6fdb64bddd841a0957adf28;hpb=14647cabb5bbb54629de8545e080519bd0be430f diff --git a/t/v2-mobile.t b/t/v2-mobile.t index 5176a52..342d06f 100644 --- a/t/v2-mobile.t +++ b/t/v2-mobile.t @@ -1,6 +1,7 @@ # (X)Emacs mode: -*- cperl -*- use strict; +use warnings; =head1 Unit Test Package for Term::ProgressBar @@ -8,11 +9,10 @@ This package tests the moving target functionality of Term::ProgressBar. =cut -use Data::Dumper qw( Dumper ); use Test::More tests => 7; use Test::Exception; -use Capture::Tiny qw(capture); +use Capture::Tiny qw(capture_stderr); use_ok 'Term::ProgressBar'; @@ -36,20 +36,19 @@ Update it from 11 to 20. =cut -my ($out, $err) = capture { +my $err = capture_stderr { my $p; lives_ok { $p = Term::ProgressBar->new(10); } 'Count 1-20 (1)'; lives_ok { $p->update($_) for 1..5 } 'Count 1-20 (2)'; lives_ok { $p->target(20) } 'Count 1-20 (3)'; lives_ok { $p->update($_) for 11..20 } 'Count 1-20 (4)'; }; -print $out; - $err =~ s!^.*\r!!gm; - print STDERR "ERR:\n$err\nlength: ", length($err), "\n" +$err =~ s!^.*\r!!gm; +diag "ERR:\n$err\nlength: " . length($err) if $ENV{TEST_DEBUG}; - my @lines = split /\n/, $err; +my @lines = split /\n/, $err; - like $lines[-1], qr/\[=+\]/, 'Count 1-20 (5)'; - like $lines[-1], qr/^\s*100%/, 'Count 1-20 (6)'; +like $lines[-1], qr/\[=+\]/, 'Count 1-20 (5)'; +like $lines[-1], qr/^\s*100%/, 'Count 1-20 (6)';