r72705 - in /branches/upstream/libtest-differences-perl/current: ./ lib/Test/ t/
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Sun Apr 17 19:57:02 UTC 2011
Author: periapt-guest
Date: Sun Apr 17 19:56:34 2011
New Revision: 72705
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=72705
Log:
[svn-upgrade] new version libtest-differences-perl (0.61)
Added:
branches/upstream/libtest-differences-perl/current/t/example.t
branches/upstream/libtest-differences-perl/current/t/flatten.t
branches/upstream/libtest-differences-perl/current/t/pass.t
branches/upstream/libtest-differences-perl/current/t/struct.t
branches/upstream/libtest-differences-perl/current/t/test.t
branches/upstream/libtest-differences-perl/current/t/text_vs_data.t
branches/upstream/libtest-differences-perl/current/t/undef.t
Removed:
branches/upstream/libtest-differences-perl/current/t/00flatten.t
branches/upstream/libtest-differences-perl/current/t/01text_vs_data.t
branches/upstream/libtest-differences-perl/current/t/02pass.t
branches/upstream/libtest-differences-perl/current/t/03struct.t
branches/upstream/libtest-differences-perl/current/t/10test.t
branches/upstream/libtest-differences-perl/current/t/99example.t
Modified:
branches/upstream/libtest-differences-perl/current/Build.PL
branches/upstream/libtest-differences-perl/current/Changes
branches/upstream/libtest-differences-perl/current/MANIFEST
branches/upstream/libtest-differences-perl/current/META.yml
branches/upstream/libtest-differences-perl/current/Makefile.PL
branches/upstream/libtest-differences-perl/current/lib/Test/Differences.pm
Modified: branches/upstream/libtest-differences-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/Build.PL?rev=72705&op=diff
==============================================================================
--- branches/upstream/libtest-differences-perl/current/Build.PL (original)
+++ branches/upstream/libtest-differences-perl/current/Build.PL Sun Apr 17 19:56:34 2011
@@ -3,16 +3,21 @@
use Module::Build;
my $builder = Module::Build->new(
- module_name => 'Test::Differences',
- license => 'perl',
- dist_author => 'Curtis "Ovid" Poe <ovid at cpan.org>',
- dist_version_from => 'lib/Test/Differences.pm',
- perl => 5.006,
- requires => {
- 'Test::More' => 0,
- 'Text::Diff' => 0.35,
+ module_name => 'Test::Differences',
+ license => 'perl',
+ dist_author => 'Curtis "Ovid" Poe <ovid at cpan.org>',
+ dist_version_from => 'lib/Test/Differences.pm',
+ perl => 5.006,
+ requires => {
+ 'Test::More' => 0,
+ 'Text::Diff' => 0.35,
+ 'Data::Dumper' => 2.126,
},
- add_to_cleanup => [ 'Test-Differences-*' ],
+ add_to_cleanup => ['Test-Differences-*'],
+ meta_merge => {
+ resources =>
+ { repository => 'https://github.com/Ovid/Test-Differences' }
+ },
);
$builder->create_build_script();
Modified: branches/upstream/libtest-differences-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/Changes?rev=72705&op=diff
==============================================================================
--- branches/upstream/libtest-differences-perl/current/Changes (original)
+++ branches/upstream/libtest-differences-perl/current/Changes Sun Apr 17 19:56:34 2011
@@ -1,4 +1,15 @@
Changes file for Test::Differences
+
+0.61 Sat April 16, 2011
+ - Allow an option to override Sortkeys in C<eq_or_diff>. Thanks to Mark
+ Zealey for the suggestion.
+ - Unnumbered tests. There's no point to them.
+
+0.60 Sat April 16, 2011
+ - Make '' and undef not equal. Thanks to Pavel Shaydo for the patch.
+ - Made Data::Dumper minimum version 2.126 to resolve
+ https://rt.cpan.org/Ticket/Display.html?id=60798. Thanks to
+ jjnapiork at cpan.org for the report and fix.
0.50 Sat Oct 17 15:18:03 2009
- Production release.
Modified: branches/upstream/libtest-differences-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/MANIFEST?rev=72705&op=diff
==============================================================================
--- branches/upstream/libtest-differences-perl/current/MANIFEST (original)
+++ branches/upstream/libtest-differences-perl/current/MANIFEST Sun Apr 17 19:56:34 2011
@@ -5,12 +5,13 @@
MANIFEST
README
t/00-load.t
-t/00flatten.t
-t/01text_vs_data.t
-t/02pass.t
-t/03struct.t
-t/10test.t
-t/99example.t
+t/flatten.t
+t/text_vs_data.t
+t/pass.t
+t/struct.t
+t/test.t
+t/undef.t
+t/example.t
t/diff_styles.t
t/boilerplate.t
t/pod-coverage.t
Modified: branches/upstream/libtest-differences-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/META.yml?rev=72705&op=diff
==============================================================================
--- branches/upstream/libtest-differences-perl/current/META.yml (original)
+++ branches/upstream/libtest-differences-perl/current/META.yml Sun Apr 17 19:56:34 2011
@@ -1,22 +1,24 @@
---
+abstract: 'Test strings and data structures and show differences if not ok'
+author:
+ - "Curtis \"Ovid\" Poe <ovid at cpan.org>"
+configure_requires:
+ Module::Build: 0.36
+generated_by: 'Module::Build version 0.3607'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
name: Test-Differences
-version: 0.500
-author:
- - 'Curtis "Ovid" Poe <ovid at cpan.org>'
-abstract: Test strings and data structures and show differences if not ok
-license: perl
-resources:
- license: http://dev.perl.org/licenses/
-requires:
- Test::More: 0
- Text::Diff: 0.35
-configure_requires:
- Module::Build: 0.35
provides:
Test::Differences:
file: lib/Test/Differences.pm
- version: 0.500
-generated_by: Module::Build version 0.35
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ version: 0.61
+requires:
+ Data::Dumper: 2.126
+ Test::More: 0
+ Text::Diff: 0.35
+resources:
+ license: http://dev.perl.org/licenses/
+ repository: https://github.com/Ovid/Test-Differences
+version: 0.61
Modified: branches/upstream/libtest-differences-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/Makefile.PL?rev=72705&op=diff
==============================================================================
--- branches/upstream/libtest-differences-perl/current/Makefile.PL (original)
+++ branches/upstream/libtest-differences-perl/current/Makefile.PL Sun Apr 17 19:56:34 2011
@@ -3,21 +3,26 @@
use ExtUtils::MakeMaker;
eval "use 5.006";
-if (my $error = $@) {
+if ( my $error = $@ ) {
warn $error;
exit 0;
}
WriteMakefile(
- NAME => 'Test::Differences',
- AUTHOR => 'Curtis "Ovid" Poe <ovid at cpan.org>',
- VERSION_FROM => 'lib/Test/Differences.pm',
- ABSTRACT_FROM => 'lib/Test/Differences.pm',
- PL_FILES => {},
- PREREQ_PM => {
- 'Test::More' => 0,
- 'Text::Diff' => 0.35,
+ NAME => 'Test::Differences',
+ AUTHOR => 'Curtis "Ovid" Poe <ovid at cpan.org>',
+ VERSION_FROM => 'lib/Test/Differences.pm',
+ ABSTRACT_FROM => 'lib/Test/Differences.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'Text::Diff' => 0.35,
+ 'Data::Dumper' => 2.126,
},
- dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- clean => { FILES => 'Test-Differences-*' },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'Test-Differences-*' },
+ META_MERGE => {
+ resources =>
+ { repository => 'https://github.com/Ovid/Test-Differences' }
+ },
);
Modified: branches/upstream/libtest-differences-perl/current/lib/Test/Differences.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/lib/Test/Differences.pm?rev=72705&op=diff
==============================================================================
--- branches/upstream/libtest-differences-perl/current/lib/Test/Differences.pm (original)
+++ branches/upstream/libtest-differences-perl/current/lib/Test/Differences.pm Sun Apr 17 19:56:34 2011
@@ -3,6 +3,10 @@
=head1 NAME
Test::Differences - Test strings and data structures and show differences if not ok
+
+=head1 VERSION
+
+0.61
=head1 SYNOPSIS
@@ -20,7 +24,7 @@
use DBI;
... open connection & prepare statement and @expected_... here...
-
+
eq_or_diff $sth->fetchall_arrayref, \@expected_arrays "testing DBI arrays";
eq_or_diff $sth->fetchall_hashref, \@expected_hashes, "testing DBI hashes";
@@ -139,14 +143,32 @@
=head1 OPTIONS
-There is currently only one option: "context". This allows you to
-control the amount of context shown:
+The options to C<eq_or_diff> give some fine-grained control over the output.
+
+=over 4
+
+=item * C<context>
+
+This allows you to control the amount of context shown:
eq_or_diff $got, $expected, $name, { context => 50000 };
will show you lots and lots of context. Normally, eq_or_diff() uses
some heuristics to determine whether to show 3 lines of context (like
a normal unified diff) or 25 lines.
+
+=item * C<data_type>
+
+C<text> or C<data>. See C<eq_or_diff_text> and C<eq_or_diff_data> to
+understand this. You can usually ignore this.
+
+=item * C<Sortkeys>
+
+If passed, whatever value is added is used as the argument for L<Data::Dumper>
+Sortkeys option. See the L<Data::Dumper> docs to understand how you can
+control the Sortkeys behavior.
+
+=back
=head1 DIFF STYLES
@@ -171,9 +193,9 @@
use Test::More 'no_plan';
use Test::Differences;
-
+
my $long_string = join '' => 1..40;
-
+
TODO: {
local $TODO = 'Testing diff styles';
@@ -192,7 +214,7 @@
eq_or_diff $long_string, "-$long_string", 'oldstyle diff';
}
-=head1 DEPLOYING
+=head1 DEPLOYING
There are several basic ways of deploying Test::Differences requiring more or less
labor by you or your users.
@@ -261,15 +283,15 @@
=cut
-our $VERSION = "0.500"; # or "0.001_001" for a dev release
+our $VERSION = "0.61"; # or "0.001_001" for a dev release
$VERSION = eval $VERSION;
use Exporter;
@ISA = qw( Exporter );
- at EXPORT = qw(
- eq_or_diff
- eq_or_diff_text
+ at EXPORT = qw(
+ eq_or_diff
+ eq_or_diff_text
eq_or_diff_data
unified_diff
context_diff
@@ -340,7 +362,7 @@
my $type = shift;
local $_ = shift if @_;
- return [ split /^/m ] unless ref;
+ return [ split /^/m, _quote_str($_) ] unless ref;
croak "Can't flatten $_" unless $type;
@@ -355,7 +377,10 @@
else {
die "unsupported ref type";
}
- if ( $type eq ARRAY_of_ARRAYs_of_scalars ) {
+ if ( $type eq ARRAY_of_scalars) {
+ @recs = map { _quote_str($_) } @recs;
+ }
+ elsif ( $type eq ARRAY_of_ARRAYs_of_scalars ) {
## Also copy the inner arrays if need be
$_ = [@$_] for @recs;
}
@@ -382,16 +407,24 @@
}
if ( $type eq ARRAY_of_ARRAYs_of_scalars ) {
- ## Convert undefs
+ ## Quote strings
for my $rec (@recs) {
for (@$rec) {
- $_ = "<undef>" unless defined;
+ $_ = _quote_str($_);
}
$rec = join ",", @$rec;
}
}
return \@recs;
+}
+
+sub _quote_str {
+ my $str = shift;
+ return 'undef' unless defined $str;
+ return $str if $str =~ /^[0-9]+$/;
+ $str =~ s{([\\\'])}{\\$1}g;
+ return "'$str'";
}
sub _identify_callers_test_package_of_choice {
@@ -443,11 +476,12 @@
if ($dump_it) {
require Data::Dumper;
local $Data::Dumper::Indent = 1;
- local $Data::Dumper::Sortkeys = 1;
local $Data::Dumper::Purity = 0;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Deepcopy = 1;
local $Data::Dumper::Quotekeys = 0;
+ local $Data::Dumper::Sortkeys =
+ exists $options->{Sortkeys} ? $options->{Sortkeys} : 1;
( $got, $expected ) = map
[ split /^/, Data::Dumper::Dumper($_) ],
@vals;
@@ -569,17 +603,17 @@
not ok 5
# Failed test (t/ctrl/05-home.t at line 51)
- # +----+------------------------+----+------------------------+
- # | Elt|Got | Elt|Expected |
- # +----+------------------------+----+------------------------+
- # | 0|{ | 0|{ |
- # | 1| 'password' => '', | 1| 'password' => '', |
- # * 2| 'method' => 'login', * | |
- # | 3| 'ctrl' => 'home', | 2| 'ctrl' => 'home', |
- # | | * 3| 'method' => 'login', *
- # | 4| 'email' => 'test' | 4| 'email' => 'test' |
- # | 5|} | 5|} |
- # +----+------------------------+----+------------------------+
+ # +----+------------------------+----+------------------------+
+ # | Elt|Got | Elt|Expected |
+ # +----+------------------------+----+------------------------+
+ # | 0|{ | 0|{ |
+ # | 1| 'password' => '', | 1| 'password' => '', |
+ # * 2| 'method' => 'login', * | |
+ # | 3| 'ctrl' => 'home', | 2| 'ctrl' => 'home', |
+ # | | * 3| 'method' => 'login', *
+ # | 4| 'email' => 'test' | 4| 'email' => 'test' |
+ # | 5|} | 5|} |
+ # +----+------------------------+----+------------------------+
Data::Dumper also overlooks the difference between
Added: branches/upstream/libtest-differences-perl/current/t/example.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/example.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/example.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/example.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,41 @@
+use strict;
+my $x;
+
+my $demo = $ENV{DEMO};
+
+eval <<'PRELOAD' ? eval <<'TEST' : ( $x = $@, eval <<'FALLBACK' );
+ use Test::More;
+ 1;
+PRELOAD
+ use Test::Differences;
+
+ plan tests => 3 ;
+
+ print "#\n# This test misuses TODO:",
+ " these TODOs are actually real tests.\n#\n"
+ unless $demo;
+ TODO: {
+ local $TODO = "testing failure, not really a TODO" unless $demo;
+ my @docs = (
+ join( "", map "this is line $_\n", qw( 1 2 3 ) ),
+ join( "", map "this is line $_\n", qw( 1 b 3 ) )
+ );
+ eq_or_diff @docs, "differences in text";
+
+ @docs = ( ( " indented\n" x 3 ) x 2 );
+
+ $docs[1] =~ s/(^..*?^)\s+/$1\t/ms or die "Can't subst \\t for ' '";
+
+ eq_or_diff @docs, "differences in whitespace";
+
+ eq_or_diff( Test::Builder->new, [ "Dry, humorless message" ] );
+ }
+TEST
+ use Test;
+
+ plan tests => 1;
+
+ skip $x, "" ;
+FALLBACK
+
+die $@ if $@;
Added: branches/upstream/libtest-differences-perl/current/t/flatten.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/flatten.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/flatten.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/flatten.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,29 @@
+use Test::More;
+
+use Test::Differences;
+
+sub flatten($) {
+ my $out = join "|",
+ @{
+ Test::Differences::_flatten( Test::Differences::_grok_type( $_[0] ),
+ $_[0] )
+ };
+ $out =~ s/ +//g;
+ $out;
+}
+## Complex data structures are not flattened, they're dumped, so don't
+## test that here.
+my @cases = (
+ "a" => "'a'",
+ "a\nb\n" => "'a\n|b\n|'",
+ [qw( a b )] => "'a'|'b'",
+ [ [qw( a b )], [qw(c d)] ] => "'a','b'|'c','d'",
+ [ { a => 0, b => 1 }, { a => 2, c => 3 } ] =>
+ "'a','b','c'|0,1,undef|2,undef,3",
+ [ 1, undef, "undef" ] => "1|undef|'undef'",
+);
+
+plan tests => @cases / 2;
+while ( my ( $data, $result ) = splice @cases, 0, 2 ) {
+ is flatten $data, $result, $result;
+}
Added: branches/upstream/libtest-differences-perl/current/t/pass.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/pass.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/pass.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/pass.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,15 @@
+use Test::More;
+use Test::Differences;
+
+# use large enough data sets that this thing chooses context => 3 instead
+# of "full document context".
+my $a = ( "\n" x 30 ) . "a\n";
+my $b = ( "\n" x 30 ) . "b\n";
+
+my @tests = (
+ sub { eq_or_diff [ "a", "b" ], [ "a", "b" ] },
+);
+
+plan tests => scalar @tests;
+
+$_->() for @tests;
Added: branches/upstream/libtest-differences-perl/current/t/struct.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/struct.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/struct.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/struct.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,19 @@
+use Test::More;
+
+use Test::Differences;
+
+## This mind-bender submitted by Yves Orton <demerphq at hotmail.com>
+my ( $ar, $x, $y );
+$ar->[0] = \$ar->[1];
+$ar->[1] = \$ar->[0];
+$x = \$y;
+$y = \$x;
+
+my @tests = (
+ sub { eq_or_diff [ \"a", \"b" ], [ \"a", \"b" ] },
+ sub { eq_or_diff $ar, [ $x, $y ] },
+);
+
+plan tests => scalar @tests;
+
+$_->() for @tests;
Added: branches/upstream/libtest-differences-perl/current/t/test.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/test.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/test.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/test.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,20 @@
+use Test::More;
+
+use Test::Differences;
+
+my @tests = (
+ sub { eq_or_diff "a", "b" },
+ sub { eq_or_diff "a\nb\nc\n", "a\nc\n" },
+ sub { eq_or_diff "a\nb\nc\n", "a\nB\nc\n" },
+ sub { eq_or_diff "a\nb\nc\nd\ne\n", "a\nc\ne\n" },
+ sub { eq_or_diff "a\nb\nc\nd\ne\n", "a\nb\nd\ne\n", { context => 0 } },
+ sub { eq_or_diff "a\nb\nc\nd\ne\n", "a\nb\nd\ne\n", { context => 10 } },
+);
+
+plan tests => scalar @tests;
+diag "This test misuses TODO: these TODOs are actually real tests.\n";
+
+TODO: {
+ local $TODO = 'Deliberate misuse of TODO';
+ $_->() for @tests;
+}
Added: branches/upstream/libtest-differences-perl/current/t/text_vs_data.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/text_vs_data.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/text_vs_data.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/text_vs_data.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,20 @@
+use Test::More;
+use Test::Differences;
+
+# use large enough data sets that this thing chooses context => 3 instead
+# of "full document context".
+my $a = ( "\n" x 30 ) . "a\n";
+my $b = ( "\n" x 30 ) . "b\n";
+
+my @tests = (
+ sub { eq_or_diff $a, $b },
+ sub { eq_or_diff_text $a, $b },
+ sub { eq_or_diff_data $a, $b },
+);
+
+plan tests => scalar @tests;
+
+TODO: {
+ local $TODO = 'Force the output to be displayed';
+ $_->() for @tests;
+}
Added: branches/upstream/libtest-differences-perl/current/t/undef.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-differences-perl/current/t/undef.t?rev=72705&op=file
==============================================================================
--- branches/upstream/libtest-differences-perl/current/t/undef.t (added)
+++ branches/upstream/libtest-differences-perl/current/t/undef.t Sun Apr 17 19:56:34 2011
@@ -1,0 +1,22 @@
+use Test::More qw(no_plan);
+use Test::Differences;
+
+TODO: {
+ local $TODO = "Should fail";
+ eq_or_diff( undef, "", "undef eq ''" );
+ eq_or_diff( undef, [], "undef eq []" );
+ eq_or_diff( undef, 0, "undef eq 0" );
+ eq_or_diff( "", 0, "'' eq 0" );
+ eq_or_diff( [ 1, undef ], [ 1, "" ], "undef eq '' in array" );
+ eq_or_diff( [ 1, [ 2, undef ] ], [ 1, [ 2, "" ] ], "undef eq '' in deep array" );
+ eq_or_diff( [ [1], [ 2, undef ] ], [ [1], [ 2, "" ] ], "undef eq '' in AoAoS" );
+ eq_or_diff( [ [1], [ 2, undef ] ], [ [1], [ 2, "<undef>" ] ], "undef eq <undef> in AoAoS" );
+ eq_or_diff( [ 1, undef ], [ 1, ], "arrays of different length are equal" );
+ eq_or_diff( { aa => undef }, { aa => '' }, "undef eq '' in hash" );
+ eq_or_diff( { aa => undef }, { aa => '<undef>' }, "undef eq <undef> in hash" );
+}
+
+my $builder = Test::More->builder;
+eq_or_diff [ map { $_->{actual_ok} } $builder->details ], [ map { 0 } $builder->details ],
+ "All TODO tests failed";
+
More information about the Pkg-perl-cvs-commits
mailing list