[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#249678: marked as done (libtest-unit-perl: Three bugs in assert_deep_equals)



Your message dated Sun, 31 Jul 2005 23:34:36 +0100
with message-id <20050731223436.GA30979@deprecation.cyrius.com>
and subject line Removed from Debian - unmaintained
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 18 May 2004 19:43:18 +0000
>From francis@contre.com Tue May 18 12:43:16 2004
Return-path: <francis@contre.com>
Received: from relais.videotron.ca [24.201.245.36] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1BQAUa-0006rd-00; Tue, 18 May 2004 12:43:12 -0700
Received: from Luhmann.Contre.COM ([24.200.44.210])
 by VL-MO-MR011.ip.videotron.ca
 (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep  8 2003))
 with ESMTP id <0HXX006DUDFXZ3@VL-MO-MR011.ip.videotron.ca> for
 submit@bugs.debian.org; Tue, 18 May 2004 15:43:09 -0400 (EDT)
Received: from Arendt.Contre.COM (Arendt.Contre.COM [192.168.250.10])
	by Luhmann.Contre.COM (Postfix) with ESMTP	id 2B72D13844; Tue,
 18 May 2004 15:43:09 -0400 (EDT)
Received: by Arendt.Contre.COM (Postfix, from userid 500)	id D21B8B7BC; Tue,
 18 May 2004 15:43:08 -0400 (EDT)
Date: Tue, 18 May 2004 15:43:08 -0400
From: "Francis J. Lacoste" <francis@Contre.COM>
Subject: libtest-unit-perl: Three bugs in assert_deep_equals
To: Debian Bug Tracking System <submit@bugs.debian.org>
Message-id: <20040518194308.D21B8B7BC@Arendt.Contre.COM>
MIME-version: 1.0
X-Mailer: reportbug 2.59
Content-type: multipart/mixed; boundary="Boundary_(ID_0HH0B70ljqZXTT/Rb5lxlg)"
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-5.5 required=4.0 tests=BAYES_30,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2004_03_25
X-Spam-Level: 

This is a multi-part MIME message sent by reportbug.

--Boundary_(ID_0HH0B70ljqZXTT/Rb5lxlg)
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

Package: libtest-unit-perl
Version: 0.24-1.1
Severity: normal
Tags: patch


I'm sending a patch which fixes three bugs in assert_deep_equals():

1) Infinite loop on cyclic data structure.
2) [ '' ] is considered equals to [ undef ]
3) { 'test' => [] } is considered equals to { 'test' => undef }

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.22+ctx
Locale: LANG=C, LC_CTYPE=fr_CA

Versions of packages libtest-unit-perl depends on:
ii  libclass-inner-perl           0.1-2      A perlish implementation of Java l
ii  libdevel-symdump-perl         2.03-3     Perl module for inspecting perl's 
ii  liberror-perl                 0.15-5     Perl module for error/exception ha
ii  perl                          5.8.4-2    Larry Wall's Practical Extraction 

-- no debconf information

--Boundary_(ID_0HH0B70ljqZXTT/Rb5lxlg)
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii;
 NAME=TestUnit-0.24-circ_deep_equals.diff
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=TestUnit-0.24-circ_deep_equals.diff

diff -ur libtest-unit-perl-0.24.debian/lib/Test/Unit/Assert.pm libtest-unit-perl-0.24/lib/Test/Unit/Assert.pm
--- libtest-unit-perl-0.24.debian/lib/Test/Unit/Assert.pm	2004-05-18 14:35:41.000000000 -0400
+++ libtest-unit-perl-0.24/lib/Test/Unit/Assert.pm	2004-05-18 15:09:53.000000000 -0400
@@ -219,6 +219,7 @@
 }
 
 # Shamelessly pinched from Test::More and adapted to Test::Unit.
+our %Seen_Refs = ();
 our @Data_Stack;
 my $DNE = bless [], 'Does::Not::Exist';
 sub assert_deep_equals {
@@ -236,23 +237,36 @@
     }
 
     local @Data_Stack = ();
+    local %Seen_Refs = ();
     if (! $self->_deep_check($this, $that)) {
         Test::Unit::Failure->throw(
             -text => @_ ? join('', @_)
                         : $self->_format_stack(@Data_Stack)
         );
     }
-}    
+}
 
 sub _deep_check {
     my $self = shift;
     my ($e1, $e2) = @_;
 
-    # Quiet uninitialized value warnings when comparing undefs.
-    local $^W = 0; 
+    if ( ! defined $e1 || ! defined $e2 ) {
+        return 1 if !defined $e1 && !defined $e2;
+        push @Data_Stack, { vals => [$e1, $e2] };
+        return 0;
+    }
+
+    return 0 if ( (defined $e1 && $e1 eq $DNE)
+                  || (defined $e2 && $e2 eq $DNE ));
 
     return 1 if $e1 eq $e2;
 
+    if ( ref $e1 && ref $e2 ) {
+        my $e2_ref = "$e2";
+        return 1 if defined $Seen_Refs{$e1} && $Seen_Refs{$e1} eq $e2_ref;
+        $Seen_Refs{$e1} = $e2_ref;
+    }
+
     if (UNIVERSAL::isa($e1, 'ARRAY') and UNIVERSAL::isa($e2, 'ARRAY')) {
         return $self->_eq_array($e1, $e2);
     }
Only in libtest-unit-perl-0.24/lib/Test/Unit: Assert.pm~
diff -ur libtest-unit-perl-0.24.debian/t/tlib/AssertTest.pm libtest-unit-perl-0.24/t/tlib/AssertTest.pm
--- libtest-unit-perl-0.24.debian/t/tlib/AssertTest.pm	2004-05-18 14:35:41.000000000 -0400
+++ libtest-unit-perl-0.24/t/tlib/AssertTest.pm	2004-05-18 15:07:56.000000000 -0400
@@ -11,6 +11,8 @@
 use Error qw/:try/;
 use Class::Inner;
 
+use Data::Dumper;
+
 use vars qw/@ISA/;
 @ISA = qw(Test::Unit::TestCase ExceptionChecker);
 
@@ -328,6 +330,19 @@
     $self->assert_not_null(10);
 }
 
+sub deep_clone {
+    my $x = $_[0];
+
+    no strict;
+
+    $Data::Dumper::Purity = 1;
+
+    eval Dumper( $x );
+
+    # Data::Dumper assigns to VAR1.
+    return $VAR1;
+}
+
 sub test_assert_deep_equals {
     my $self = shift;
 
@@ -366,6 +381,30 @@
         },
     );
 
+    my %family = ( john => { name => 'John Doe',
+                              spouse => undef,
+                              children => [],
+                           },
+                   jane => { name   => 'Jane Doe',
+                             spouse => undef,
+                             children => [],
+                           },
+                   baby => { name => 'Baby Doll',
+                             spouse => undef,
+                             children => [],
+                           },
+                 );
+    $family{john}{spouse} = $family{jane};
+    $family{jane}{spouse} = $family{john};
+    push @{$family{john}{children}}, $family{baby};
+    push @{$family{jane}{children}}, $family{baby};
+
+    my $copy = deep_clone( \%family );
+    $self->assert_deep_equals( \%family, $copy );
+
+    my $bad_copy = deep_clone( \%family );
+    $bad_copy->{jane}{spouse} = $bad_copy->{baby};
+
     my $differ = sub {
         my ($a, $b) = @_;
         qr/^Structures\ begin\ differing\ at: $ \n
@@ -381,6 +420,12 @@
         'Both arguments were not references' => [ '', 0    ],
          $differ->(qw/ARRAY HASH/)     => [ [],      {}      ],
          $differ->(qw/ARRAY HASH/)     => [ [1,2],   {1,2}   ],
+         $differ->( 'ARRAY', 'undef' ) => [ { 'test' => []}, 
+                                            { 'test' => undef } ],
+         $differ->( 'ARRAY', 'not\ exist' ) => [ { 'test' => []}, {} ],
+         $differ->( 'undef', 'ARRAY' ) => [ { 'test' => undef },
+                                            { 'test' => []} ],
+         $differ->( '', 'undef' ) => [ [ '' ], [ undef ] ],
          $differ->('not\ exist', "'3'") => [ [1,2],   [1,2,3] ],
          $differ->("'3'", 'not\ exist') => [ [1,2,3], [1,2]   ],
          $differ->("'wahhhhh'", "'wahhhh'") => [
@@ -398,6 +443,7 @@
                  },
              }
          ],
+         $differ->( 'HASH', 'undef') => [ \%family, $bad_copy ],
     );
 
     my @tests = ();
Only in libtest-unit-perl-0.24/t/tlib: AssertTest.pm~

--Boundary_(ID_0HH0B70ljqZXTT/Rb5lxlg)--

---------------------------------------
Received: (at 249678-done) by bugs.debian.org; 31 Jul 2005 22:35:07 +0000
>From tbm@cyrius.com Sun Jul 31 15:35:07 2005
Return-path: <tbm@cyrius.com>
Received: from sorrow.cyrius.com [65.19.161.204] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1DzMOh-0000AR-00; Sun, 31 Jul 2005 15:35:07 -0700
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id 639FD64D54; Sun, 31 Jul 2005 22:34:57 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id 75BED84B0; Sun, 31 Jul 2005 23:34:36 +0100 (BST)
Date: Sun, 31 Jul 2005 23:34:36 +0100
From: Martin Michlmayr <tbm@cyrius.com>
To: 197445-done@bugs.debian.org, 225003-done@bugs.debian.org,
	249678-done@bugs.debian.org
Subject: Removed from Debian - unmaintained
Message-ID: <20050731223436.GA30979@deprecation.cyrius.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.9i
Delivered-To: 249678-done@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-3.0 required=4.0 tests=BAYES_00 autolearn=no 
	version=2.60-bugs.debian.org_2005_01_02
X-CrossAssassin-Score: 142

This package has now been removed from Debian because nobody was
interested in maintaining it; see
http://lists.debian.org/debian-devel-announce/2005/06/msg00014.html
for more information.

-- 
Martin Michlmayr
http://www.cyrius.com/



Reply to: