Permalink
Browse files

100% test coverage FTW

  • Loading branch information...
1 parent 993f30d commit 0ec77f3f80121771f21067ec739fc568590f9dda @xsawyerx committed May 5, 2010
Showing with 28 additions and 1 deletion.
  1. +1 −0 MANIFEST
  2. +1 −1 lib/Algorithm/Diff/Callback.pm
  3. +22 −0 t/croak.t
  4. +4 −0 t/diff_hashes.t
View
@@ -4,6 +4,7 @@ lib/Algorithm/Diff/Callback.pm
MANIFEST
README
t/00-load.t
+t/croak.t
t/diff_arrays.t
t/diff_hashes.t
t/manifest.t
@@ -57,7 +57,7 @@ sub diff_arrays {
} elsif ( $change eq '-' ) {
$del_cb->($value);
} else {
- croak "Can't recognize change in changeset: '$change'\n";
+ croak "Can't recognize change in changeset: '$change'";
}
}
}
View
@@ -0,0 +1,22 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Algorithm::Diff::Callback 'diff_arrays';
+
+{
+ no warnings qw/redefine once/;
+ *Algorithm::Diff::Callback::diff = sub { return ( [ [ '*', 0, 'ack' ] ] ) };
+ use warnings;
+}
+
+my @old = qw( one two );
+my @new = qw( one four );
+$|++;
+
+eval { diff_arrays( \@old, \@new, sub {}, sub {} ) };
+ok( $@, 'Caught error' );
+
+like( $@, qr/Can't recognize change in changeset\: '\*'/, 'Unknown change' );
View
@@ -8,12 +8,16 @@ use Algorithm::Diff::Callback 'diff_hashes';
my %old = (
tvshow => 'Psych',
+ book => 'Damnation Game',
band => 'Catharsis',
+ movie => undef,
);
my %new = (
tvshow => 'CSI (Las Vegas)', # new favorite tv show
+ book => 'Damnation Game', # <3 Cliver Barker
artist => 'Michael Jackson', # ah, the classics
+ movie => undef, # decisions, decisions
);
diff_hashes(

0 comments on commit 0ec77f3

Please sign in to comment.