Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

100% test coverage FTW

  • Loading branch information...
commit 0ec77f3f80121771f21067ec739fc568590f9dda 1 parent 993f30d
@xsawyerx authored
View
1  MANIFEST
@@ -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
View
2  lib/Algorithm/Diff/Callback.pm
@@ -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
22 t/croak.t
@@ -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
4 t/diff_hashes.t
@@ -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(
Please sign in to comment.
Something went wrong with that request. Please try again.