[PATCH 01/14] move to using Test::More

"Sven Dowideit" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
From: Sven Dowideit <[email protected]>

---
 Changes     |    6 ++++++
 MANIFEST    |    2 +-
 Makefile.PL |    8 +++++++-
 t/pod.t     |   12 ++++++++++++
 t/test.t    |   42 ++++++++++++++++++++++++++++++++++++++++++
 t/test.t~   |   40 ++++++++++++++++++++++++++++++++++++++++
 test.pl     |   36 ------------------------------------
 7 files changed, 108 insertions(+), 38 deletions(-)
 create mode 100644 t/pod.t
 create mode 100755 t/test.t
 create mode 100755 t/test.t~
 delete mode 100755 test.pl

diff --git a/Changes b/Changes
index 6ee137a..f51a7df 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,12 @@ AnyData - easy access to data in many formats
 
 Revision history for Perl extension AnyData.
 
+version 0.11, released  Aug 2012
+
+ * new maintainer Sven Dowideit
+ * use Test::More
+ *
+
 version 0.10, released 19 April 2004
 
  * really fixed adConvert, thanks for bug reports - Dan Wright, Scott Godin
diff --git a/MANIFEST b/MANIFEST
index 4936bca..f803a04 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -22,7 +22,7 @@ AnyData/Storage/FileSys.pm
 AnyData/Storage/PassThru.pm
 AnyData/Storage/RAM.pm
 AnyData/Storage/TiedHash.pm
-test.pl
+t/pod.t
 
 
 
diff --git a/Makefile.PL b/Makefile.PL
index 2e95307..7ebef28 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -8,9 +8,15 @@ my %opts =
      'VERSION_FROM' => 'AnyData.pm',
      'dist'         => { 'SUFFIX'       => ".gz",
 			 'DIST_DEFAULT' => 'all tardist',
-			 'COMPRESS'     => "gzip -9vf" }
+			 'COMPRESS'     => "gzip -9vf" },
+          'PREREQ_PM' => {
+                           'Test::More' => '0.9'
+                         },			 
      );
 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
     $opts{'AUTHOR'} = 'Jeff Zucker ([email protected])';
 }
 ExtUtils::MakeMaker::WriteMakefile(%opts);
+
+
+
diff --git a/t/pod.t b/t/pod.t
new file mode 100644
index 0000000..ee8b18a
--- /dev/null
+++ b/t/pod.t
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();
diff --git a/t/test.t b/t/test.t
new file mode 100755
index 0000000..b9cf639
--- /dev/null
+++ b/t/test.t
@@ -0,0 +1,42 @@
+#!/usr/local/bin/perl -wT
+use strict;
+use warnings;
+
+#the original tests that came with AnyData 0.10
+
+my @formats = qw(CSV Pipe Tab Fixed Paragraph ARRAY);
+
+use Test::More;
+plan tests => (1+$#formats) * 4;
+
+use AnyData;
+
+
+for my $format( @formats ) {
+   printf  "  %10s ... %s\n", $format, test_ad($format);
+}
+
+sub test_ad {
+    my $file = [];
+    my $format = shift;
+    my $mode = 'o';
+    my $flags = {cols=>'name,country,sex',pattern=>'A5 A8 A3'};
+    my $table = adTie( $format,$file, $mode, $flags ); # create a table
+    $table->{Sue} = {country=>'fr',sex=>'f'};          # insert rows
+    $table->{Tom} = {country=>'fr',sex=>'f'};
+    $table->{Bev} = {country=>'en',sex=>'f'};
+    $table->{{ name=>'Tom'}} = {sex=>'m'};             # update a row
+    delete $table->{Bev};                              # delete a row
+    $flags = {pattern=>'A5 A8 A3'};
+    ok('f' eq $table->{Sue}->{sex}, "Failed single select");
+    my $tstr;
+    while ( my $person = each %$table ) {              # select mulitple rows
+        $tstr .= $person->{name} if $person->{country} eq 'fr';
+    }
+    ok('SueTom' eq $tstr, "Failed multiple select");
+    ok('namecountrysex' eq join('',adNames($table)), "Failed names");
+    ok(2 == adRows($table), "Failed rows");
+}
+
+
+__END__
diff --git a/t/test.t~ b/t/test.t~
new file mode 100755
index 0000000..30d5abc
--- /dev/null
+++ b/t/test.t~
@@ -0,0 +1,40 @@
+#!/usr/local/bin/perl -wT
+use strict;
+use warnings;
+
+my @formats = qw(CSV Pipe Tab Fixed Paragraph ARRAY);
+
+use Test::More;
+plan tests => (1+$#formats) * 4;
+
+use AnyData;
+
+
+for my $format( @formats ) {
+   printf  "  %10s ... %s\n", $format, test_ad($format);
+}
+
+sub test_ad {
+    my $file = [];
+    my $format = shift;
+    my $mode = 'o';
+    my $flags = {cols=>'name,country,sex',pattern=>'A5 A8 A3'};
+    my $table = adTie( $format,$file, $mode, $flags ); # create a table
+    $table->{Sue} = {country=>'fr',sex=>'f'};          # insert rows
+    $table->{Tom} = {country=>'fr',sex=>'f'};
+    $table->{Bev} = {country=>'en',sex=>'f'};
+    $table->{{ name=>'Tom'}} = {sex=>'m'};             # update a row
+    delete $table->{Bev};                              # delete a row
+    $flags = {pattern=>'A5 A8 A3'};
+    ok('f' eq $table->{Sue}->{sex}, "Failed single select");
+    my $tstr;
+    while ( my $person = each %$table ) {              # select mulitple rows
+        $tstr .= $person->{name} if $person->{country} eq 'fr';
+    }
+    ok('SueTom' eq $tstr, "Failed multiple select");
+    ok('namecountrysex' eq join('',adNames($table)), "Failed names");
+    ok(2 == adRows($table), "Failed rows");
+}
+
+
+__END__
diff --git a/test.pl b/test.pl
deleted file mode 100755
index a788be1..0000000
--- a/test.pl
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/local/bin/perl -w
-use strict;
-use AnyData;
-print "\nUsing AnyData $AnyData::VERSION\n\n";
-my @formats = qw(CSV Pipe Tab Fixed Paragraph ARRAY);
-
-for my $format( @formats ) {
-   printf  "  %10s ... %s\n", $format, test_ad($format);
-}
-
-sub test_ad {
-    my $file = [];
-    my $format = shift;
-    my $mode = 'o';
-    my $flags = {cols=>'name,country,sex',pattern=>'A5 A8 A3'};
-    my $table = adTie( $format,$file, $mode, $flags ); # create a table
-    $table->{Sue} = {country=>'fr',sex=>'f'};          # insert rows
-    $table->{Tom} = {country=>'fr',sex=>'f'};
-    $table->{Bev} = {country=>'en',sex=>'f'};
-    $table->{{ name=>'Tom'}} = {sex=>'m'};             # update a row
-    delete $table->{Bev};                              # delete a row
-    $flags = {pattern=>'A5 A8 A3'};
-    return "Failed single select"
-        unless 'f' eq $table->{Sue}->{sex};            # select a single value
-    my $tstr;
-    while ( my $person = each %$table ) {              # select mulitple rows
-        $tstr .= $person->{name} if $person->{country} eq 'fr';
-    }
-    return "Failed multiple select"  unless 'SueTom' eq $tstr;
-    return "Failed names" unless 'namecountrysex' eq join '',adNames($table);
-    return "Failed rows"  unless 2 == adRows($table);
-    return 'ok';
-}
-
-
-__END__
-- 
1.7.10.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.