r31495 - in /branches/upstream/libtest-deep-perl/current: CHANGES META.yml lib/Test/Deep.pm lib/Test/Deep.pod t/bag.t
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Fri Mar 6 06:20:47 UTC 2009
Author: ryan52-guest
Date: Fri Mar 6 06:20:39 2009
New Revision: 31495
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=31495
Log:
[svn-upgrade] Integrating new upstream version, libtest-deep-perl (0.104)
Modified:
branches/upstream/libtest-deep-perl/current/CHANGES
branches/upstream/libtest-deep-perl/current/META.yml
branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pm
branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pod
branches/upstream/libtest-deep-perl/current/t/bag.t
Modified: branches/upstream/libtest-deep-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-deep-perl/current/CHANGES?rev=31495&op=diff
==============================================================================
--- branches/upstream/libtest-deep-perl/current/CHANGES (original)
+++ branches/upstream/libtest-deep-perl/current/CHANGES Fri Mar 6 06:20:39 2009
@@ -1,3 +1,11 @@
+0.104
+
+Document behaviour of cmp_bag when a non ARRAY-ref argument is passed
+to it. Explicity test for this a die with a useful message.
+
+Document and export cmp_details and deep_diag, thanks to Tom Hukins
+for the patch.
+
0.103
Detect whether isa() is being called with 1 or 2 arguments and
Modified: branches/upstream/libtest-deep-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-deep-perl/current/META.yml?rev=31495&op=diff
==============================================================================
--- branches/upstream/libtest-deep-perl/current/META.yml (original)
+++ branches/upstream/libtest-deep-perl/current/META.yml Fri Mar 6 06:20:39 2009
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Test-Deep
-version: 0.103
+version: 0.104
version_from: ./lib/Test/Deep.pm
installdirs: perl
requires:
Modified: branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pm?rev=31495&op=diff
==============================================================================
--- branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pm (original)
+++ branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pm Fri Mar 6 06:20:39 2009
@@ -25,18 +25,18 @@
$Snobby $Expects $DNE $DNE_ADDR $Shallow
);
-$VERSION = '0.103';
+$VERSION = '0.104';
require Exporter;
@ISA = qw( Exporter );
@EXPORT = qw( eq_deeply cmp_deeply cmp_set cmp_bag cmp_methods
- useclass noclass set bag subbagof superbagof subsetof supersetof
- superhashof subhashof
+ useclass noclass set bag subbagof superbagof subsetof
+ supersetof superhashof subhashof
);
# plus all the ones generated from %constructors below
- at EXPORT_OK = qw( descend render_stack deep_diag class_base );
+ at EXPORT_OK = qw( descend render_stack class_base cmp_details deep_diag );
$Snobby = 1; # should we compare classes?
$Expects = 0; # are we comparing got vs expect or expect vs expect
@@ -477,7 +477,10 @@
sub cmp_bag
{
local $Test::Builder::Level = $Test::Builder::Level + 1;
- return cmp_deeply(shift, bag(@{shift()}), shift);
+ my $ref = ref($_[1]) || "";
+ confess "Argument 2 to cmp_bag is not an ARRAY ref (".render_val($_[1]).")"
+ unless $ref eq "ARRAY";
+ return cmp_deeply(shift, bag(@{shift()}), shift);
}
sub superhashof
Modified: branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pod?rev=31495&op=diff
==============================================================================
--- branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pod (original)
+++ branches/upstream/libtest-deep-perl/current/lib/Test/Deep.pod Fri Mar 6 06:20:39 2009
@@ -281,6 +281,9 @@
Is shorthand for cmp_deeply(\@got, bag(@bag), $name)
+N.B. Both arguments must be array refs. If they aren't an error will
+be raised via die.
+
=head3 $ok = cmp_set(\@got, \@set, $name)
Is shorthand for cmp_deeply(\@got, set(@set), $name)
@@ -301,6 +304,17 @@
otherwise the L<Test::Builder> framework will be loaded and testing messages
will be output when your program ends.
+
+=head3 ($ok, $stack) = cmp_details($got, $expected)
+
+This behaves much like eq_deeply, but it additionally allows you to
+produce diagnostics in case of failure by passing the value in C<$stack>
+to C<deep_diag>.
+
+Do not make assumptions about the structure or content of C<$stack> and
+do not use it if C<$ok> contains a true value.
+
+See L</USING TEST::DEEP WITH TEST::BUILDER> for example uses.
=head1 SPECIAL COMPARISONS PROVIDED
@@ -768,6 +782,16 @@
cmp_deeply("Brian", \&check_name);
+=head1 DIAGNOSTIC FUNCTIONS
+
+=head3 my $reason = deep_diag($stack)
+
+C<$stack> is a value returned by cmp_details. Do not call this function
+if cmp_details returned a true value for C<$ok>.
+
+deep_diag() returns a human readable string describing how the
+comparison failed.
+
=head1 ANOTHER EXAMPLE
You've written a module to handle people and their film interests. Say you
@@ -827,7 +851,32 @@
)
);
-=head1 LIMITITATIONS
+=head1 USING TEST::DEEP WITH TEST::BUILDER
+
+Combining C<cmp_details> and C<test_diag> makes it possible to use
+Test::Deep in your own test classes.
+
+In a L<Test::Builder> subclass, create a test method in the following
+form:
+
+ sub behaves_ok {
+ my $self = shift;
+ my $expected = shift;
+ my $test_name = shift;
+
+ my $got = do_the_important_work_here();
+
+ my ($ok, $stack) = cmp_details($got, $expected);
+ unless ($Test->ok($ok, $test_name)) {
+ my $diag = deep_diag($stack);
+ $Test->diag($diag);
+ }
+ }
+
+As the subclass defines a test class, not tests themselves, make sure it
+uses L<Test::Deep::NoTest>, not C<Test::Deep> itself.
+
+=head1 LIMITATIONS
Currently any CODE, GLOB or IO refs will be compared using shallow(), which
means only their memory addresses are compared.
Modified: branches/upstream/libtest-deep-perl/current/t/bag.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-deep-perl/current/t/bag.t?rev=31495&op=diff
==============================================================================
--- branches/upstream/libtest-deep-perl/current/t/bag.t (original)
+++ branches/upstream/libtest-deep-perl/current/t/bag.t Fri Mar 6 06:20:39 2009
@@ -243,4 +243,12 @@
},
"subbagof no"
);
+
+ eval {
+ my @res = run_tests(
+ sub { cmp_bag([], {}) }
+ )
+ };
+ like($@, qr/Argument 2 to cmp_bag is not an ARRAY ref \(HASH.*\)/,
+ "check arg 1")
}
More information about the Pkg-perl-cvs-commits
mailing list