testing updates
authorShawn Boyette <sboyette@esilibrary.com>
Tue, 24 Mar 2009 20:41:07 +0000 (20:41 +0000)
committerShawn Boyette <sboyette@esilibrary.com>
Tue, 24 Mar 2009 20:41:07 +0000 (20:41 +0000)
Equinox-Migration/lib/Equinox/Migration.pm
Equinox-Migration/lib/Equinox/Migration/SimpleTagList.pm
Equinox-Migration/lib/Equinox/Migration/SubfieldMapper.pm
Equinox-Migration/t/01-SimpleTagList.t
Equinox-Migration/t/02-SubfieldMapper.t

index 8a7a504..c86eedb 100644 (file)
@@ -27,27 +27,6 @@ Perhaps a little code snippet.
     my $foo = Equinox::Migration->new();
     ...
 
-=head1 EXPORT
-
-A list of functions that can be exported.  You can delete this section
-if you don't export anything, such as for a purely object-oriented module.
-
-=head1 FUNCTIONS
-
-=head2 function1
-
-=cut
-
-sub function1 {
-}
-
-=head2 function2
-
-=cut
-
-sub function2 {
-}
-
 =head1 AUTHOR
 
 Shawn Boyette, C<< <sboyette at esilibrary.com> >>
index 6a27328..6bac8df 100644 (file)
@@ -178,6 +178,8 @@ sub add_tag {
     my ($self, $tag) = @_;
     $tag =~ s/^0+//;
 
+    die "Values must be numeric\n" if ($tag =~ /[^\d\-]/);
+
     die "Values must be valid tags (0-999)\n"
       unless ($tag >= 0 and $tag <= 999);
 
index 285b465..7d6f069 100644 (file)
@@ -228,7 +228,7 @@ sub validate {
      unless ($toks->{field} =~ /^[a-zA-z]/);
 
     die "Invalid tag (line $.)\n"
-      if ($toks->{tag} =~ /\D/ or $toks->{tag} < 0 or $toks->{tag} > 999);
+      if ($toks->{tag} =~ /[^\d\-]/ or $toks->{tag} < 0 or $toks->{tag} > 999);
 
     die "Invalid subfield code (line $.)\n"
       if (length $toks->{sub} != 1 or $toks->{sub} =~ /[^a-zA-Z0-9]/);
index 8a6bc7d..e6be8e7 100644 (file)
@@ -1,9 +1,14 @@
 #!perl -T
 
-use Test::More tests => 33;
+#use Test::More tests => 34;
+use Test::More qw(no_plan);
+
 use Equinox::Migration::SimpleTagList;
 
 # baseline object creation
+eval { my $stl = Equinox::Migration::SimpleTagList->new( file => "thefileisalie.txt" ) };
+is ($@ =~ /^Can't open tags file:/, 1, 'cannot open that');
+
 my $stl = Equinox::Migration::SimpleTagList->new();
 is(ref $stl, "Equinox::Migration::SimpleTagList", "self is self");
 
@@ -16,6 +21,13 @@ is ($stl->has(904), 1, 'can has tag');
 $stl->remove_tag(904);
 is ($stl->has(904), 0, 'can not has tag');
 
+eval { $stl->add_tag('q') };
+is ($@, "Values must be numeric\n");
+eval { $stl->add_tag(-37) };
+is ($@, "Values must be valid tags (0-999)\n");
+eval { $stl->add_tag(1027) };
+is ($@, "Values must be valid tags (0-999)\n");
+
 # range addition, as_hashref, as_listref
 $stl->add_range("198..201");
 is_deeply ($stl->as_hashref, { 89 => 1, 198 => 1, 199 => 1, 200 => 1, 201 => 1 });
@@ -23,6 +35,16 @@ is_deeply ($stl->as_listref, [ 89, 198, 199, 200, 201 ]);
 $stl->add_range("008..011");
 is_deeply ($stl->as_listref, [ 8, 9, 10, 11, 89, 198, 199, 200, 201 ]);
 
+$stl->{conf}{except} = 1;
+eval { $stl->add_range("300..311") };
+is ($@, "Exception ranges must be within last addition range (300..311)\n");
+eval { $stl->add_range("10..311") };
+is ($@, "Exception ranges must be within last addition range (10..311)\n");
+eval { $stl->add_range("6..11") };
+is ($@, "Exception ranges must be within last addition range (6..11)\n");
+
+
+
 # creation with file
 $stl = Equinox::Migration::SimpleTagList->new( file => "./t/corpus/stl-0.txt");
 is ($stl->has(11), 1);
index 568c3c0..d1095a5 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -T
 
-#use Test::More tests => 33;
-use Test::More qw(no_plan);
+use Test::More tests => 39;
+#use Test::More qw(no_plan);
 use Equinox::Migration::SubfieldMapper;
 
 # baseline object creation