1 #!/usr/local/bin/perl -w
6 use Algorithm::Diff qw( traverse_sequences ) ;
8 my @A = map "$_\n", qw( 1 a 2 b 3 ) ;
9 my @B = map "$_\n", qw( 1 A 2 B 3 ) ;
11 ## This tests both that we can overload all 5 methods and that all 5
12 ## methods are called by diff() (and in the right order :)
14 my $f = "My::Diff::Format" ;
15 my $diff = diff \@A, \@B, { CONTEXT => 0, STYLE => $f } ;
19 if ( $diff =~ /(^${f}::.*){8}/sm ) {
23 ok $diff, "8 lines of output" ;
42 ok $diff, "proper ordering (see test source)" ;
48 plan tests => scalar @tests ;
52 package My::Diff::Format ;
57 my $prefix = (caller(1))[3] ;
58 local $Data::Dumper::Indent = 0 ;
59 local $Data::Dumper::Terse = 1 ;
62 map { s/^/$prefix: /mg ; $_ ; } join ", ", map {
63 my $s = ref $_ ? Dumper $_ : $_ ;
64 $s =~ s/([\000-\026])/sprintf "\0x%02x", ord $1/ge ;
70 sub file_header { &_dump }
71 sub hunk_header { &_dump }
73 sub hunk_footer { &_dump }
74 sub file_footer { &_dump }