]> git.donarmstrong.com Git - term-progressbar.git/commitdiff
switch from Test to Test::More
authorGabor Szabo <gabor@szabgab.com>
Tue, 29 Nov 2011 20:32:38 +0000 (22:32 +0200)
committerGabor Szabo <gabor@szabgab.com>
Tue, 29 Nov 2011 20:32:38 +0000 (22:32 +0200)
t/compat.t
t/eta-linear.t
t/name.t
t/test.pm
t/v1-message.t
t/v2-message.t
t/v2-mobile.t
t/v2-simple.t
t/zero.t

index daba215626f1c3c3a78abc918112ec4bb9539954..3698e57aa88747db68e22b82455cdda21ca3df76 100644 (file)
@@ -12,15 +12,7 @@ and is intended to test compatibility with that version.
 # Utility -----------------------------
 
 use Data::Dumper qw( );
 # Utility -----------------------------
 
 use Data::Dumper qw( );
-use Test qw( ok plan );
-
-# Test Setup --------------------------
-
-BEGIN {
-  plan tests => 5,
-       todo  => [],
-       ;
-}
+use Test::More tests => 4;
 
 # -------------------------------------
 
 
 # -------------------------------------
 
@@ -68,23 +60,9 @@ sub grab_output($) {
     return [ $o, $e ];
 }
 
     return [ $o, $e ];
 }
 
-# Change 1..1 below to 1..last_test_to_print .
-# (It may become useful if the test is moved to ./t subdirectory.)
-
 use Term::ProgressBar;
 use POSIX qw<floor ceil>;
 
 use Term::ProgressBar;
 use POSIX qw<floor ceil>;
 
-=head2 Test 1: compilation
-
-This test confirms that the test script and the modules it calls compiled
-successfully.
-
-=cut
-
-ok 1, 1, 'compilation';
-
-# -------------------------------------
-
 $| = 1;
 
 my $count = 100;
 $| = 1;
 
 my $count = 100;
@@ -99,7 +77,7 @@ if (not $b or $o->[0] ne '' or $o->[1] ne "$test_str: ") {
       if $ENV{TEST_DEBUG};
     print 'not ';
 }
       if $ENV{TEST_DEBUG};
     print 'not ';
 }
-print "ok 2\n";
+ok 1;
 
 # Test 3: do half the stuff and check half the bar has printed
 my $halfway = floor($count / 2);
 
 # Test 3: do half the stuff and check half the bar has printed
 my $halfway = floor($count / 2);
@@ -111,7 +89,7 @@ if ($o->[0] ne ''
       if $ENV{TEST_DEBUG};
     print 'not ';
 }
       if $ENV{TEST_DEBUG};
     print 'not ';
 }
-print "ok 3\n";
+ok 1;
 
 # Test 4: do the rest of the stuff and check the whole bar has printed
 $o = grab_output("update \$b foreach ($halfway .. $count - 1)");
 
 # Test 4: do the rest of the stuff and check the whole bar has printed
 $o = grab_output("update \$b foreach ($halfway .. $count - 1)");
@@ -122,7 +100,7 @@ if ($o->[0] ne ''
       if $ENV{TEST_DEBUG};
     print 'not ';
 }
       if $ENV{TEST_DEBUG};
     print 'not ';
 }
-print "ok 4\n";
+ok 1;
 
 # Test 5: try to do another item and check there is an error
 eval { update $b };
 
 # Test 5: try to do another item and check there is an error
 eval { update $b };
@@ -134,4 +112,4 @@ unless ( defined($@)
     if $ENV{TEST_DEBUG};
   print 'not ';
 }
     if $ENV{TEST_DEBUG};
   print 'not ';
 }
-print "ok 5\n";
+ok 1;
index 0de0594ad6a4ad3e6b46e03786dd96bc94eb383d..ea8410d27c8b3e85212e28b9ee2721dbf98b5343 100644 (file)
@@ -10,17 +10,11 @@ This package tests the basic functionality of Term::ProgressBar.
 
 use Data::Dumper  qw( Dumper );
 use FindBin       qw( $Bin );
 
 use Data::Dumper  qw( Dumper );
 use FindBin       qw( $Bin );
-use Test          qw( ok plan );
+use Test::More tests => 9;
 
 use lib $Bin;
 use test qw( evcheck );
 
 
 use lib $Bin;
 use test qw( evcheck );
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 10,
-       todo   => [],
-}
-
 =head2 Test 1: compilation
 
 This test confirms that the test script and the modules it calls compiled
 =head2 Test 1: compilation
 
 This test confirms that the test script and the modules it calls compiled
@@ -30,8 +24,6 @@ successfully.
 
 use Term::ProgressBar;
 
 
 use Term::ProgressBar;
 
-ok 1, 1, 'compilation';
-
 Term::ProgressBar->__force_term (50);
 
 # -------------------------------------
 Term::ProgressBar->__force_term (50);
 
 # -------------------------------------
@@ -61,26 +53,26 @@ my ($out, $err) = capture {
                 $p = Term::ProgressBar->new({count => 10, name => 'fred',
                                              ETA => 'linear'});
               }, 'Count 1-10 (1)' ),
                 $p = Term::ProgressBar->new({count => 10, name => 'fred',
                                              ETA => 'linear'});
               }, 'Count 1-10 (1)' ),
-      1, 'Count 1-10 (1)');
+      'Count 1-10 (1)');
   ok (evcheck(sub { for (1..5) { $p->update($_); sleep 1 } },
               'Count 1-10 (2)' ),
   ok (evcheck(sub { for (1..5) { $p->update($_); sleep 1 } },
               'Count 1-10 (2)' ),
-      1, 'Count 1-10 (2)');
+      'Count 1-10 (2)');
   ok (evcheck(sub { $p->message('Hello Mum!') },
               'Count 1-10 (3)' ),
   ok (evcheck(sub { $p->message('Hello Mum!') },
               'Count 1-10 (3)' ),
-      1, 'Count 1-10 (3)');
+      'Count 1-10 (3)');
   ok (evcheck(sub { for (6..10) { $p->update($_); sleep 1 } },
               'Count 1-10 (4)' ),
   ok (evcheck(sub { for (6..10) { $p->update($_); sleep 1 } },
               'Count 1-10 (4)' ),
-      1, 'Count 1-10 (4)');
+      'Count 1-10 (4)');
 };
 print $out;
   my @lines = grep $_ ne '', split /[\n\r]+/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
   ok grep $_ eq 'Hello Mum!', @lines;
 };
 print $out;
   my @lines = grep $_ ne '', split /[\n\r]+/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
   ok grep $_ eq 'Hello Mum!', @lines;
-  ok $lines[-1], qr/\[=+\]/,                                  'Count 1-10 (6)';
-  ok $lines[-1], qr/^fred: \s*100%/,                          'Count 1-10 (7)';
-  ok $lines[-1], qr/D[ \d]\dh\d{2}m\d{2}s$/,                  'Count 1-10 (8)';
-  ok $lines[-2], qr/ Left$/,                                  'Count 1-10 (9)';
+  like $lines[-1], qr/\[=+\]/,                                  'Count 1-10 (6)';
+  like $lines[-1], qr/^fred: \s*100%/,                          'Count 1-10 (7)';
+  like $lines[-1], qr/D[ \d]\dh\d{2}m\d{2}s$/,                  'Count 1-10 (8)';
+  like $lines[-2], qr/ Left$/,                                  'Count 1-10 (9)';
 
 
 # ----------------------------------------------------------------------------
 
 
 # ----------------------------------------------------------------------------
index 09ea43237849cb6b1b2d90953f74061b728f0699..565779fcd8c3f06f742467766d69b4f2317e97aa 100644 (file)
--- a/t/name.t
+++ b/t/name.t
@@ -10,7 +10,7 @@ This package tests the name functionality of Term::ProgressBar.
 
 use Data::Dumper  qw( Dumper );
 use FindBin       qw( $Bin );
 
 use Data::Dumper  qw( Dumper );
 use FindBin       qw( $Bin );
-use Test          qw( ok plan );
+use Test::More tests => 18;
 
 use lib $Bin;
 use test qw( evcheck );
 
 use lib $Bin;
 use test qw( evcheck );
@@ -19,11 +19,6 @@ use constant MESSAGE1 => 'The Gospel of St. Jude';
 use constant NAME1    => 'Algenon';
 use constant NAME2    => 'Smegma';
 
 use constant NAME1    => 'Algenon';
 use constant NAME2    => 'Smegma';
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 18,
-       todo   => [],
-}
 
 =head2 Test 1: compilation
 
 
 =head2 Test 1: compilation
 
@@ -32,9 +27,7 @@ successfully.
 
 =cut
 
 
 =cut
 
-use Term::ProgressBar;
-
-ok 1, 1, 'compilation';
+use_ok 'Term::ProgressBar';
 
 Term::ProgressBar->__force_term (50);
 
 
 Term::ProgressBar->__force_term (50);
 
@@ -65,9 +58,9 @@ my ($out, $err) = capture {
   ok (evcheck(sub {
                 $p = Term::ProgressBar->new({count => 10, name => NAME1});
               },                                            'Count 1-10 ( 1)'),
   ok (evcheck(sub {
                 $p = Term::ProgressBar->new({count => 10, name => NAME1});
               },                                            'Count 1-10 ( 1)'),
-      1,                                                    'Count 1-10 ( 1)');
+                                                          'Count 1-10 ( 1)');
   ok (evcheck(sub { $p->update($_) for 1..3  },             'Count 1-10 ( 2)'),
   ok (evcheck(sub { $p->update($_) for 1..3  },             'Count 1-10 ( 2)'),
-      1,                                                    'Count 1-10 ( 2)');
+                                                          'Count 1-10 ( 2)');
 };
 print $out;
 
 };
 print $out;
 
@@ -76,7 +69,7 @@ print $out;
     if $ENV{TEST_DEBUG};
   my @lines = split /\n/, $err;
 
     if $ENV{TEST_DEBUG};
   my @lines = split /\n/, $err;
 
-  ok $lines[-1], qr/^@{[NAME1()]}: \s*\b30%/,                'Count 1-10 ( 3)';
+  like $lines[-1], qr/^@{[NAME1()]}: \s*\b30%/,                'Count 1-10 ( 3)';
   my ($bar, $space) = $lines[-1] =~ /\[(=*)(\s*)\]/;
   my $length = length($bar) + length($space);
   print STDERR
   my ($bar, $space) = $lines[-1] =~ /\[(=*)(\s*)\]/;
   my $length = length($bar) + length($space);
   print STDERR
@@ -89,9 +82,9 @@ print $out;
 ($out, $err) = capture {
 
   ok (evcheck(sub { $p->message(MESSAGE1)    },             'Count 1-10 ( 5)'),
 ($out, $err) = capture {
 
   ok (evcheck(sub { $p->message(MESSAGE1)    },             'Count 1-10 ( 5)'),
-      1,                                                    'Count 1-10 ( 5)');
+                                                          'Count 1-10 ( 5)');
   ok (evcheck(sub { $p->update($_) for 6..10 },             'Count 1-10 ( 6)'),
   ok (evcheck(sub { $p->update($_) for 6..10 },             'Count 1-10 ( 6)'),
-      1,                                                    'Count 1-10 ( 6)');
+                                                          'Count 1-10 ( 6)');
 };
 print $out;
 
 };
 print $out;
 
@@ -101,9 +94,9 @@ print $out;
 
   @lines = split /\n/, $err;
 
 
   @lines = split /\n/, $err;
 
-  ok $lines[0], MESSAGE1,                                    'Count 1-10 ( 7)';
-  ok $lines[-1], qr/\[=+\]/,                                 'Count 1-10 ( 8)';
-  ok $lines[-1], qr/^@{[NAME1()]}: \s*100%/,                 'Count 1-10 ( 9)';
+  is $lines[0], MESSAGE1,                                    'Count 1-10 ( 7)';
+  like $lines[-1], qr/\[=+\]/,                                 'Count 1-10 ( 8)';
+  like $lines[-1], qr/^@{[NAME1()]}: \s*100%/,                 'Count 1-10 ( 9)';
 }
 
 # -------------------------------------
 }
 
 # -------------------------------------
@@ -131,9 +124,9 @@ Use v1 mode
 my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new(NAME2, 10); }, 
                                                             'Count 1-10 ( 1)'),
 my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new(NAME2, 10); }, 
                                                             'Count 1-10 ( 1)'),
-      1,                                                    'Count 1-10 ( 1)');
+                                                          'Count 1-10 ( 1)');
   ok (evcheck(sub { $p->update($_) for 1..3  },             'Count 1-10 ( 2)'),
   ok (evcheck(sub { $p->update($_) for 1..3  },             'Count 1-10 ( 2)'),
-      1,                                                    'Count 1-10 ( 2)');
+                                                          'Count 1-10 ( 2)');
 };
 print $out;
 
 };
 print $out;
 
@@ -142,7 +135,7 @@ print $out;
     if $ENV{TEST_DEBUG};
   my @lines = split /\n/, $err;
 
     if $ENV{TEST_DEBUG};
   my @lines = split /\n/, $err;
 
-  ok $lines[-1], qr/^@{[NAME2()]}: \s*\b30%/,                'Count 1-10 ( 3)';
+  like $lines[-1], qr/^@{[NAME2()]}: \s*\b30%/,                'Count 1-10 ( 3)';
   my ($bar, $space) = $lines[-1] =~ /(\#*)(\s*)/;
   my $length = length($bar) + length($space);
   print STDERR
   my ($bar, $space) = $lines[-1] =~ /(\#*)(\s*)/;
   my $length = length($bar) + length($space);
   print STDERR
@@ -154,9 +147,9 @@ print $out;
   
 ($out, $err) = capture {
   ok (evcheck(sub { $p->message(MESSAGE1)    },             'Count 1-10 ( 5)'),
   
 ($out, $err) = capture {
   ok (evcheck(sub { $p->message(MESSAGE1)    },             'Count 1-10 ( 5)'),
-      1,                                                    'Count 1-10 ( 5)');
+                                                          'Count 1-10 ( 5)');
   ok (evcheck(sub { $p->update($_) for 6..10 },             'Count 1-10 ( 6)'),
   ok (evcheck(sub { $p->update($_) for 6..10 },             'Count 1-10 ( 6)'),
-      1,                                                    'Count 1-10 ( 6)');
+                                                          'Count 1-10 ( 6)');
 };
 print $out;
   $err =~ s!^.*\r!!gm;
 };
 print $out;
   $err =~ s!^.*\r!!gm;
@@ -165,8 +158,8 @@ print $out;
 
   @lines = split /\n/, $err;
 
 
   @lines = split /\n/, $err;
 
-  ok $lines[-1], qr/^@{[NAME2()]}: \s*\d+% \#*$/,            'Count 1-10 ( 8)';
-  ok $lines[-1], qr/^@{[NAME2()]}: \s*100%/,                 'Count 1-10 ( 9)';
+  like $lines[-1], qr/^@{[NAME2()]}: \s*\d+% \#*$/,            'Count 1-10 ( 8)';
+  like $lines[-1], qr/^@{[NAME2()]}: \s*100%/,                 'Count 1-10 ( 9)';
 }
 
 # -------------------------------------
 }
 
 # -------------------------------------
index 1025f4e332a887f71cd975145c94133af01d6e21..f72ae085821bc3aec006892ee6c97bd40737d4dc 100644 (file)
--- a/t/test.pm
+++ b/t/test.pm
@@ -8,19 +8,6 @@ test - tools for helping in test suites (not including running externalprograms)
 
 =head1 SYNOPSIS
 
 
 =head1 SYNOPSIS
 
-  use FindBin               1.42 qw( $Bin );
-  use Test                  1.13 qw( ok plan );
-
-  BEGIN { unshift @INC, $Bin };
-
-  use test                  qw(   evcheck runcheck );
-
-  BEGIN {
-    plan tests  => 3,
-         todo   => [],
-         ;
-  }
-
   ok evcheck(sub {
                open my $fh, '>', 'foo';
                print $fh "$_\n"
   ok evcheck(sub {
                open my $fh, '>', 'foo';
                print $fh "$_\n"
index 550ab7953b63f979bd4d6543fd00103032bba32c..0b43108094d8f0fca03969025bcf91beb65525ec 100644 (file)
@@ -10,19 +10,13 @@ This package tests the basic functionality of Term::ProgressBar.
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
-use Test         qw( ok plan );
+use Test::More tests => 8;
 
 use lib $Bin;
 use test qw( evcheck );
 
 use constant MESSAGE1 => 'Walking on the Milky Way';
 
 
 use lib $Bin;
 use test qw( evcheck );
 
 use constant MESSAGE1 => 'Walking on the Milky Way';
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 8,
-       todo   => [],
-}
-
 =head2 Test 1: compilation
 
 This test confirms that the test script and the modules it calls compiled
 =head2 Test 1: compilation
 
 This test confirms that the test script and the modules it calls compiled
@@ -30,9 +24,8 @@ successfully.
 
 =cut
 
 
 =cut
 
-use Term::ProgressBar;
+use_ok 'Term::ProgressBar';
 
 
-ok 1, 1, 'compilation';
 
 Term::ProgressBar->__force_term (50);
 
 
 Term::ProgressBar->__force_term (50);
 
@@ -58,13 +51,13 @@ my ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new('bob', 10); },
               'Count 1-10 (1)' ),
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new('bob', 10); },
               'Count 1-10 (1)' ),
-      1, 'Count 1-10 (1)');
+      'Count 1-10 (1)');
   ok (evcheck(sub { $p->update($_) for 1..5  }, 'Count 1-10 (2)' ),
   ok (evcheck(sub { $p->update($_) for 1..5  }, 'Count 1-10 (2)' ),
-      1, 'Count 1-10 (2)');
+      'Count 1-10 (2)');
   ok (evcheck(sub { $p->message(MESSAGE1)    }, 'Count 1-10 (3)' ),
   ok (evcheck(sub { $p->message(MESSAGE1)    }, 'Count 1-10 (3)' ),
-      1, 'Count 1-10 (3)');
+      'Count 1-10 (3)');
   ok (evcheck(sub { $p->update($_) for 6..10 }, 'Count 1-10 (4)' ),
   ok (evcheck(sub { $p->update($_) for 6..10 }, 'Count 1-10 (4)' ),
-      1, 'Count 1-10 (4)');
+      'Count 1-10 (4)');
 };
 print $out;
 
 };
 print $out;
 
@@ -74,6 +67,6 @@ print $out;
 
   my @lines = split /\n/, $err;
 
 
   my @lines = split /\n/, $err;
 
-  ok $lines[0], MESSAGE1;
-  ok $lines[-1], qr/bob:\s+\d+% \#+/,            'Count 1-10 (6)';
-  ok $lines[-1], qr/^bob:\s+100%/,               'Count 1-10 (7)';
+  is $lines[0], MESSAGE1;
+  like $lines[-1], qr/bob:\s+\d+% \#+/,            'Count 1-10 (6)';
+  like $lines[-1], qr/^bob:\s+100%/,               'Count 1-10 (7)';
index 5b215be694b1e30950ae431cea3b94d4dffa07cb..c4036e3f9544a08dd5b0d43ab336d6bba6aa2bb9 100644 (file)
@@ -10,7 +10,7 @@ This package tests the basic functionality of Term::ProgressBar.
 
 use Data::Dumper 2.101 qw( Dumper );
 use FindBin 1.42 qw( $Bin );
 
 use Data::Dumper 2.101 qw( Dumper );
 use FindBin 1.42 qw( $Bin );
-use Test 1.122 qw( ok plan );
+use Test::More tests => 11;
 
 use lib $Bin;
 use test qw( evcheck );
 
 use lib $Bin;
 use test qw( evcheck );
@@ -19,11 +19,6 @@ use constant MESSAGE1 => 'Walking on the Milky Way';
 
 use Capture::Tiny qw(capture);
 
 
 use Capture::Tiny qw(capture);
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 11,
-       todo   => [],
-}
 
 =head2 Test 1: compilation
 
 
 =head2 Test 1: compilation
 
@@ -32,9 +27,7 @@ successfully.
 
 =cut
 
 
 =cut
 
-use Term::ProgressBar;
-
-ok 1, 1, 'compilation';
+use_ok 'Term::ProgressBar';
 
 Term::ProgressBar->__force_term (50);
 
 
 Term::ProgressBar->__force_term (50);
 
@@ -58,13 +51,13 @@ Update it it from 1 to 10.  Output a message halfway through.
 my ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-10 (1)' ),
 my ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-10 (1)' ),
-      1, 'Count 1-10 (1)');
+      'Count 1-10 (1)');
   ok (evcheck(sub { $p->update($_) for 1..5  }, 'Count 1-10 (2)' ),
   ok (evcheck(sub { $p->update($_) for 1..5  }, 'Count 1-10 (2)' ),
-      1, 'Count 1-10 (2)');
+      'Count 1-10 (2)');
   ok (evcheck(sub { $p->message(MESSAGE1)    }, 'Count 1-10 (3)' ),
   ok (evcheck(sub { $p->message(MESSAGE1)    }, 'Count 1-10 (3)' ),
-      1, 'Count 1-10 (3)');
+      'Count 1-10 (3)');
   ok (evcheck(sub { $p->update($_) for 6..10 }, 'Count 1-10 (4)' ),
   ok (evcheck(sub { $p->update($_) for 6..10 }, 'Count 1-10 (4)' ),
-      1, 'Count 1-10 (4)');
+      'Count 1-10 (4)');
 };
 print $out;
 
 };
 print $out;
 
@@ -74,9 +67,9 @@ print $out;
 
   my @lines = split /\n/, $err;
 
 
   my @lines = split /\n/, $err;
 
-  ok $lines[0], MESSAGE1;
-  ok $lines[-1], qr/\[=+\]/,            'Count 1-10 (5)';
-  ok $lines[-1], qr/^\s*100%/,          'Count 1-10 (6)';
+  is $lines[0], MESSAGE1;
+  like $lines[-1], qr/\[=+\]/,            'Count 1-10 (5)';
+  like $lines[-1], qr/^\s*100%/,          'Count 1-10 (6)';
 
 # -------------------------------------
 
 
 # -------------------------------------
 
@@ -94,15 +87,15 @@ This is to check that message preserves the progress bar value correctly.
 ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new(100); }, 'Message Check ( 1)'),
 ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new(100); }, 'Message Check ( 1)'),
-      1,                                                 'Message Check ( 1)');
+                                                      'Message Check ( 1)');
   ok (evcheck(sub { for (0..100) { $p->update($_); $p->message("Hello") } },
               'Message Check ( 2)',), 
   ok (evcheck(sub { for (0..100) { $p->update($_); $p->message("Hello") } },
               'Message Check ( 2)',), 
-      1,                                                 'Message Check ( 2)');
+                                                      'Message Check ( 2)');
 };
 print $out;
 
   my @err_lines = split /\n/, $err;
   (my $last_line = $err_lines[-1]) =~ tr/\r//d;
 };
 print $out;
 
   my @err_lines = split /\n/, $err;
   (my $last_line = $err_lines[-1]) =~ tr/\r//d;
-  ok substr($last_line, 0, 4), '100%',               'Message Check ( 3)';
+  is substr($last_line, 0, 4), '100%',               'Message Check ( 3)';
 
 # ----------------------------------------------------------------------------
 
 # ----------------------------------------------------------------------------
index dca40621682c94ed8f55849f35c29b9283a6f713..5021f2d6f3a4cd20e218a3d3f8f933fd6f5dc62b 100644 (file)
@@ -10,29 +10,14 @@ This package tests the moving target functionality of Term::ProgressBar.
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
-use Test         qw( ok plan );
+use Test::More tests => 7;
 
 use lib $Bin;
 use test qw( evcheck );
 
 use Capture::Tiny qw(capture);
 
 
 use lib $Bin;
 use test qw( evcheck );
 
 use Capture::Tiny qw(capture);
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 7,
-       todo   => [],
-}
-
-=head2 Test 1: compilation
-
-This test confirms that the test script and the modules it calls compiled
-successfully.
-
-=cut
-
-use Term::ProgressBar;
-
-ok 1, 1, 'compilation';
+use_ok 'Term::ProgressBar';
 
 Term::ProgressBar->__force_term (50);
 
 
 Term::ProgressBar->__force_term (50);
 
@@ -57,13 +42,13 @@ Update it from 11 to 20.
 my ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-20 (1)' ),
 my ($out, $err) = capture {
   my $p;
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-20 (1)' ),
-      1, 'Count 1-20 (1)');
+      'Count 1-20 (1)');
   ok (evcheck(sub { $p->update($_) for 1..5  },  'Count 1-20 (2)' ),
   ok (evcheck(sub { $p->update($_) for 1..5  },  'Count 1-20 (2)' ),
-      1, 'Count 1-20 (2)');
+      'Count 1-20 (2)');
   ok (evcheck(sub { $p->target(20)    },         'Count 1-20 (3)' ),
   ok (evcheck(sub { $p->target(20)    },         'Count 1-20 (3)' ),
-      1, 'Count 1-20 (3)');
+      'Count 1-20 (3)');
   ok (evcheck(sub { $p->update($_) for 11..20 }, 'Count 1-20 (4)' ),
   ok (evcheck(sub { $p->update($_) for 11..20 }, 'Count 1-20 (4)' ),
-      1, 'Count 1-20 (4)');
+      'Count 1-20 (4)');
 };
 print $out;
 
 };
 print $out;
 
@@ -73,5 +58,5 @@ print $out;
 
   my @lines = split /\n/, $err;
 
 
   my @lines = split /\n/, $err;
 
-  ok $lines[-1], qr/\[=+\]/,            'Count 1-20 (5)';
-  ok $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)';
index 5b300ba6a153d2d086c81b1878027084685e0b14..3bb54f784c4ee4c3b86b97f8724c74d79146cc9f 100644 (file)
@@ -10,29 +10,14 @@ This package tests the basic functionality of Term::ProgressBar.
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
-use Test         qw( ok plan );
+use Test::More tests => 31;
 
 use lib $Bin;
 use test qw( evcheck );
 
 use Capture::Tiny qw(capture);
 
 
 use lib $Bin;
 use test qw( evcheck );
 
 use Capture::Tiny qw(capture);
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 31,
-       todo   => [],
-}
-
-=head2 Test 1: compilation
-
-This test confirms that the test script and the modules it calls compiled
-successfully.
-
-=cut
-
-use Term::ProgressBar;
-
-ok 1, 1, 'compilation';
+use_ok 'Term::ProgressBar';
 
 Term::ProgressBar->__force_term (50);
 
 
 Term::ProgressBar->__force_term (50);
 
@@ -55,17 +40,17 @@ Update it it from 1 to 10.
 
 my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-10 (1)' ),
 
 my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-10 (1)' ),
-      1, 'Count 1-10 (1)');
+      'Count 1-10 (1)');
   ok (evcheck(sub { $p->update($_) for 1..10 }, 'Count 1-10 (2)' ),
   ok (evcheck(sub { $p->update($_) for 1..10 }, 'Count 1-10 (2)' ),
-      1, 'Count 1-10 (2)');
+      'Count 1-10 (2)');
 };
 print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
 };
 print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
-  ok $lines[-1], qr/\[=+\]/,            'Count 1-10 (3)';
-  ok $lines[-1], qr/^\s*100%/,          'Count 1-10 (4)';
-  ok $lines[$_], qr/\[[= ]+\]/, sprintf('Count 1-10 (%d)', 5+$_)
+  like $lines[-1], qr/\[=+\]/,            'Count 1-10 (3)';
+  like $lines[-1], qr/^\s*100%/,          'Count 1-10 (4)';
+  like $lines[$_], qr/\[[= ]+\]/, sprintf('Count 1-10 (%d)', 5+$_)
     for 0..10;
 }
 # -------------------------------------
     for 0..10;
 }
 # -------------------------------------
@@ -88,18 +73,18 @@ Update it it from 1 to 9.
 
 my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-9 (1)' ),
 
 my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new(10); }, 'Count 1-9 (1)' ),
-      1, 'Count 1-9 (1)');
+      'Count 1-9 (1)');
   ok (evcheck(sub { $p->update($_) for 1..9 }, 'Count 1-9 (2)' ),
   ok (evcheck(sub { $p->update($_) for 1..9 }, 'Count 1-9 (2)' ),
-      1, 'Count 1-9 (2)');
+      'Count 1-9 (2)');
 };
 print $out;
 
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
 };
 print $out;
 
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
-  ok $lines[-1], qr/\[=+ +\]/,          'Count 1-9 (3)';
-  ok $lines[-1], qr/^\s*90%/,           'Count 1-9 (4)';
-  ok $lines[$_], qr/\[[= ]+\]/, sprintf('Count 1-9 (%d)', 5+$_)
+  like $lines[-1], qr/\[=+ +\]/,          'Count 1-9 (3)';
+  like $lines[-1], qr/^\s*90%/,           'Count 1-9 (4)';
+  like $lines[$_], qr/\[[= ]+\]/, sprintf('Count 1-9 (%d)', 5+$_)
     for 0..9;
 }
 # -------------------------------------
     for 0..9;
 }
 # -------------------------------------
@@ -120,5 +105,5 @@ print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
-  ok scalar @lines, 1;
+  is scalar @lines, 1;
 }
 }
index 7461163054fb3bf1cf0bf346715d471b63418b72..8e6426b978648577ad1c0bb62ff62ee895a211bf 100644 (file)
--- a/t/zero.t
+++ b/t/zero.t
@@ -10,29 +10,14 @@ This package tests the zero-progress handling of progress bar.
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
 
 use Data::Dumper qw( Dumper );
 use FindBin      qw( $Bin );
-use Test         qw( ok plan );
+use Test::More tests => 9;
 
 use Capture::Tiny qw(capture);
 
 use lib $Bin;
 use test qw( evcheck );
 
 
 use Capture::Tiny qw(capture);
 
 use lib $Bin;
 use test qw( evcheck );
 
-BEGIN {
-  # 1 for compilation test,
-  plan tests  => 9,
-       todo   => [],
-}
-
-=head2 Test 1: compilation
-
-This test confirms that the test script and the modules it calls compiled
-successfully.
-
-=cut
-
-use Term::ProgressBar;
-
-ok 1, 1, 'compilation';
+use_ok 'Term::ProgressBar';
 
 Term::ProgressBar->__force_term (50);
 
 
 Term::ProgressBar->__force_term (50);
 
@@ -57,16 +42,16 @@ my ($out, $err)  = capture {
   $name = 'doing nothing';
   ok (evcheck(sub { $p = Term::ProgressBar->new($name, 0); },
         'V1 mode ( 1)' ),
   $name = 'doing nothing';
   ok (evcheck(sub { $p = Term::ProgressBar->new($name, 0); },
         'V1 mode ( 1)' ),
-      1,                                                       'V1 mode ( 1)');
+                                                             'V1 mode ( 1)');
   ok (evcheck(sub { $p->update($_) for 1..10 },'V1 mode ( 2)'),
   ok (evcheck(sub { $p->update($_) for 1..10 },'V1 mode ( 2)'),
-      1,                                                       'V1 mode ( 2)');
+                                                             'V1 mode ( 2)');
 };
 print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
 };
 print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
-  ok $lines[-1], qr/^$name:/,                                  'V1 mode ( 3)';
-  ok $lines[-1], qr/\(nothing to do\)/,                        'V1 mode ( 4)';
+  like $lines[-1], qr/^$name:/,                                  'V1 mode ( 3)';
+  like $lines[-1], qr/\(nothing to do\)/,                        'V1 mode ( 4)';
 }
 
 # -------------------------------------
 }
 
 # -------------------------------------
@@ -90,16 +75,16 @@ my ($out, $err) = capture {
   ok (evcheck(sub { $p = Term::ProgressBar->new({ count => 0,
                                                   name => $name }); },
         'V2 mode ( 1)' ),
   ok (evcheck(sub { $p = Term::ProgressBar->new({ count => 0,
                                                   name => $name }); },
         'V2 mode ( 1)' ),
-      1,                                                       'V2 mode ( 1)');
+                                                            'V2 mode ( 1)');
   ok (evcheck(sub { $p->update($_) for 1..10 },'V2 mode ( 2)'),
   ok (evcheck(sub { $p->update($_) for 1..10 },'V2 mode ( 2)'),
-      1,                                                       'V2 mode ( 2)');
+                                                            'V2 mode ( 2)');
 };
 print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
 };
 print $out;
   my @lines = grep $_ ne '', split /\r/, $err;
   print Dumper \@lines
     if $ENV{TEST_DEBUG};
-  ok $lines[-1], qr/^$name:/,                                  'V2 mode ( 3)';
-  ok $lines[-1], qr/\(nothing to do\)/,                        'V2 mode ( 4)';
+  like $lines[-1], qr/^$name:/,                                  'V2 mode ( 3)';
+  like $lines[-1], qr/\(nothing to do\)/,                        'V2 mode ( 4)';
 }
 
 # ----------------------------------------------------------------------------
 }
 
 # ----------------------------------------------------------------------------