Dne Pá 20.čen.2014 08:14:42, ppisar napsal(a):
Show quoted text> Dne Čt 18.čec.2013 12:29:19, ppisar napsal(a):
> > 0.25 as well as 0.25_1325 fails t/assert.t with perl-5.18 randomly
> > (output for 0.25_1325):
> >
> > not ok ERROR test_assert_deep_equals
> > t/tlib/AssertTest.pm:573 -
> > test_assert_deep_equals(Class::Inner::__A24)
> > Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\
> > at:
> > $ \n
> > \S*\s* \$a .* = .* (?-x:HASH) .* $ \n
> > \S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin
> > differing at:
> > $a->{john}{spouse}{spouse}{name} = 'John Doe'
> > $b->{john}{spouse}{spouse}{name} = 'Baby Doll'
> > '
[...]
Show quoted text>
> This looks like the regular expression does not cover all difference
> the assert_deep_equals() can discover. Like the one presented in the
> test failure.
Attached patch fixes it.
-- Petr
From f34895d59eb4e8d5c266a14e0e7ecba4bf6bb35c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 20 Jun 2014 14:33:02 +0200
Subject: [PATCH] Accept all family differences in the AssertTest test
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The t/assert.t's AssertTest test failed randomly depending on order of
hash key traversal:
not ok ERROR test_assert_deep_equals
t/tlib/AssertTest.pm:500 - test_assert_deep_equals(Class::Inner::__A20)
Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\ at: $ \n
\S*\s* \$a .* = .* (?-x:HASH) .* $ \n
\S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin differing at:
$a->{john}{spouse}{spouse}{name} = 'John Doe'
$b->{john}{spouse}{spouse}{name} = 'Baby Doll'
'
This fixes the test to accept the difference in spouse's name.
CPAN RT#87017
Signed-off-by: Petr PÃsaÅ <ppisar@redhat.com>
---
t/tlib/AssertTest.pm | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/t/tlib/AssertTest.pm b/t/tlib/AssertTest.pm
index 7310874..42fa860 100644
--- a/t/tlib/AssertTest.pm
+++ b/t/tlib/AssertTest.pm
@@ -404,10 +404,22 @@ sub test_assert_deep_equals {
);
my $differ = sub {
- my ($a, $b) = @_;
- qr/^Structures\ begin\ differing\ at: $ \n
- \S*\s* \$a .* = .* (?-x:$a) .* $ \n
- \S*\s* \$b .* = .* (?-x:$b)/mx;
+ my ($a, $b, $c, $d) = @_;
+ if (defined $d) {
+ qr/^Structures\ begin\ differing\ at: $ \n
+ (?:
+ \S*\s* \$a .* = .* (?-x:$a) .* $ \n
+ \S*\s* \$b .* = .* (?-x:$b)
+ |
+ \S*\s* \$a .* = .* (?-x:$c) .* $ \n
+ \S*\s* \$b .* = .* (?-x:$d)
+ )
+ /mx,
+ } else {
+ qr/^Structures\ begin\ differing\ at: $ \n
+ \S*\s* \$a .* = .* (?-x:$a) .* $ \n
+ \S*\s* \$b .* = .* (?-x:$b)/mx;
+ }
};
my %families; # key=test-purpose, value=assorted circular structures
@@ -481,7 +493,7 @@ sub test_assert_deep_equals {
},
}
],
- $differ->( 'HASH', 'not exist') => [$families{orig}, $families{bad_copy}], # test may be fragile due to recursion ordering?
+ $differ->( 'HASH', 'not exist', 'John Doe', 'Baby Doll') => [$families{orig}, $families{bad_copy}], # test may be fragile due to recursion ordering?
$differ->("'3'", "'5'") => [ [ \$H, 3 ], [ \$H2, 5 ] ],
$differ->("'hello'", "'goodbye'") => [ { world => \$H }, { world => \$G } ],
$differ->("'hello'", "'goodbye'") => [ [ \$H, "world" ], [ \$G, "world" ] ],
--
1.9.3