better logging, use Data::Dump if available [0.14]
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 6 Jul 2006 20:31:46 +0000 (20:31 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 6 Jul 2006 20:31:46 +0000 (20:31 +0000)
git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@45 4670fa4d-42ec-0310-ab5b-a66af6943492

lib/Biblio/Isis.pm
t/002_isis.t

index 5461657..da1fcd7 100644 (file)
@@ -4,12 +4,10 @@ use strict;
 use Carp;
 use File::Glob qw(:globally :nocase);
 
-use Data::Dumper;
-
 BEGIN {
        use Exporter ();
        use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-       $VERSION     = 0.13;
+       $VERSION     = 0.14;
        @ISA         = qw (Exporter);
        #Give a hoot don't pollute, do not export more than needed by default
        @EXPORT      = qw ();
@@ -153,7 +151,16 @@ sub new {
                }
        }
 
-       print STDERR "## using files: ",join(" ",@isis_files),"\n" if ($self->{debug});
+       if ($self->{debug}) {
+               print STDERR "## using files: ",join(" ",@isis_files),"\n";
+               eval "use Data::Dump";
+
+               if (! $@) {
+                       *Dumper = *Data::Dump::dump;
+               } else {
+                       use Data::Dumper;
+               }
+       }
 
        # if you want to read .FDT file use read_fdt argument when creating class!
        if ($self->{read_fdt} && -e $self->{fdt_file}) {
@@ -202,7 +209,7 @@ sub new {
        read($self->{'fileMST'}, $buff, 4) || croak "can't read NXTMFN from MST: $!";
        $self->{'NXTMFN'}=unpack("V",$buff) || croak "NXTNFN is zero";
 
-       print STDERR Dumper($self),"\n" if ($self->{debug});
+       print STDERR "## self ",Dumper($self),"\n" if ($self->{debug});
 
        # open files for later
        open($self->{'fileXRF'}, $self->{xrf_file}) || croak "can't open '$self->{xrf_file}': $!";
index 72f0398..c031d94 100755 (executable)
@@ -3,12 +3,22 @@
 use strict;
 use blib;
 
-use Data::Dumper;
-
 use Test::More tests => 110;
 use File::Spec;
 
-BEGIN { use_ok( 'Biblio::Isis' ); }
+my $emulate_dump = 0;
+
+BEGIN {
+       use_ok( 'Biblio::Isis' );
+       eval "use Data::Dump";
+
+       if (! $@) {
+               *Dumper = *Data::Dump::dump;
+       } else {
+               use Data::Dumper;
+       }
+}
+
 
 my $debug = shift @ARGV;
 my $isis;
@@ -98,6 +108,9 @@ sub test_data {
        } ];
                
        foreach my $mfn (1 .. $isis->count) {
+
+               diag "row: ",Dumper( $data->[$mfn-1] );
+
                my $rec;
                ok($rec = $isis->fetch($mfn), "fetch $mfn");
 
@@ -105,7 +118,7 @@ sub test_data {
                        my $i = 0;
                        foreach my $v (@{$data->[$mfn-1]->{$f}}) {
                                $v =~ s/^[01# ][01# ]// if ($args->{no_ident});
-                               cmp_ok($v, '==', $rec->{$f}->[$i], "MFN $mfn $f:$i $v");
+                               cmp_ok($v, 'eq', $rec->{$f}->[$i], "MFN $mfn $f:$i $v");
                                $i++;
                        }
                }
@@ -132,7 +145,7 @@ $isis = Biblio::Isis->new (
        debug => $debug,
 );
 
-print Dumper($isis);
+diag "isis-new result: ", Dumper($isis);
 
 test_data(
        no_ident => 1,