Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updating MANIFEST and MANIFEST.SKIP

  • Loading branch information...
commit 993f30dac2ced6e6e5253ca5ba034c9e80d4d05c 1 parent 5378ba0
@xsawyerx authored
Showing with 62 additions and 1 deletion.
  1. +3 −1 MANIFEST
  2. +2 −0  MANIFEST.SKIP
  3. +57 −0 t/diff_hashes.t
View
4 MANIFEST
@@ -1,9 +1,11 @@
Build.PL
Changes
+lib/Algorithm/Diff/Callback.pm
MANIFEST
README
-lib/Algorithm/Diff/Callback.pm
t/00-load.t
+t/diff_arrays.t
+t/diff_hashes.t
t/manifest.t
t/pod-coverage.t
t/pod.t
View
2  MANIFEST.SKIP
@@ -4,6 +4,8 @@
^Makefile$
^blib/
^MakeMaker-\d
+^_build/
+^Build$
# Temp, old and emacs backup files.
~$
View
57 t/diff_hashes.t
@@ -0,0 +1,57 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 11;
+use Algorithm::Diff::Callback 'diff_hashes';
+
+my %old = (
+ tvshow => 'Psych',
+ band => 'Catharsis',
+);
+
+my %new = (
+ tvshow => 'CSI (Las Vegas)', # new favorite tv show
+ artist => 'Michael Jackson', # ah, the classics
+);
+
+diff_hashes(
+ \%old, \%new,
+ sub {
+ my ( $name, $val ) = @_;
+ is( $name, 'band', 'Band was removed' );
+ is( $val, 'Catharsis', 'Correct band' );
+ },
+ sub {
+ my ( $name, $val ) = @_;
+ is( $name, 'artist', 'Artist added' );
+ is( $val, 'Michael Jackson', 'Correct artist' );
+ },
+ sub {
+ my ( $name, $before, $after ) = @_;
+ is( $name, 'tvshow', 'Changing tv show' );
+ is( $before, 'Psych', 'Was Psych' );
+ is( $after, 'CSI (Las Vegas)', 'It is now CSI Las Vegas!' );
+ },
+);
+
+my $empty_hash = 0;
+my $cb = sub { $empty_hash++ };
+diff_hashes( {}, {}, $cb, $cb, $cb );
+cmp_ok( $empty_hash, '==', 0, 'Empty hash does not get called' );
+
+my $no_change = 0;
+$cb = sub { $no_change++ };
+diff_hashes( \%old, \%old, $cb, $cb, $cb );
+cmp_ok( $no_change, '==', 0, 'No change does not get called' );
+
+my $new_count = 0;
+my $change_count = 0;
+diff_hashes(
+ {}, \%new,
+ sub { $new_count-- }, sub { $new_count++ }, sub { $change_count++ },
+);
+
+cmp_ok( $new_count, '==', scalar keys (%new), 'New from scratch' );
+cmp_ok( $change_count, '==', 0, 'Nothing changed' );
Please sign in to comment.
Something went wrong with that request. Please try again.