[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-test-cvs
Subject:    cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestUtil.pm
From:       stas () apache ! org
Date:       2004-04-12 19:53:42
Message-ID: 20040412195342.77799.qmail () minotaur ! apache ! org
[Download RAW message or body]

stas        2004/04/12 12:53:42

  Modified:    perl-framework/Apache-Test/lib/Apache TestUtil.pm
  Log:
   because of the prototype and recursive call to itself a forward
   declaration is needed
  
  Revision  Changes    Path
  1.38      +47 -41    httpd-test/perl-framework/Apache-Test/lib/Apache/TestUtil.pm
  
  Index: TestUtil.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestUtil.pm,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -u -r1.37 -r1.38
  --- TestUtil.pm	12 Apr 2004 19:34:13 -0000	1.37
  +++ TestUtil.pm	12 Apr 2004 19:53:42 -0000	1.38
  @@ -49,6 +49,52 @@
   use constant HAS_DUMPER => eval { $] >= 5.6 && require Data::Dumper; };
   use constant INDENT     => 4;
   
  +# because of the prototype and recursive call to itself a forward
  +# declaration is needed
  +sub t_is_equal ($$);
  +
  +# compare any two datastructures (must pass references for non-scalars)
  +# undef()'s are valid args
  +sub t_is_equal ($$) {
  +    my ($a, $b) = @_;
  +    return 0 unless @_ == 2;
  +
  +    if (defined $a && defined $b) {
  +        my $ref_a = ref $a;
  +        my $ref_b = ref $b;
  +        if (!$ref_a && !$ref_b) {
  +            return $a eq $b;
  +        }
  +        elsif ($ref_a eq 'ARRAY' && $ref_b eq 'ARRAY') {
  +            return 0 unless @$a == @$b;
  +            for my $i (0..$#$a) {
  +                t_is_equal($a->[$i], $b->[$i]) || return 0;
  +            }
  +        }
  +        elsif ($ref_a eq 'HASH' && $ref_b eq 'HASH') {
  +            return 0 unless (keys %$a) == (keys %$b);
  +            for my $key (sort keys %$a) {
  +                return 0 unless exists $b->{$key};
  +                t_is_equal($a->{$key}, $b->{$key}) || return 0;
  +            }
  +        }
  +        elsif ($ref_a eq 'Regexp') {
  +            return $b =~ $a;
  +        }
  +        else {
  +            # try to compare the references
  +            return $a eq $b;
  +        }
  +    }
  +    else {
  +        # undef == undef! a valid test
  +        return (defined $a || defined $b) ? 0 : 1;
  +    }
  +    return 1;
  +}
  +
  +
  +
   sub t_cmp ($$;$) {
       Carp::carp(join(":", (caller)[1..2]) . 
           ' usage: $res = t_cmp($expected, $received, [$comment])')
  @@ -57,7 +103,7 @@
       t_debug("testing : " . pop) if @_ == 3;
       t_debug("expected: " . struct_as_string(0, $_[0]));
       t_debug("received: " . struct_as_string(0, $_[1]));
  -    return t_is_equal(@_);
  +    return t_is_equal($_[0], $_[1]);
   }
   
   *expand = HAS_DUMPER ?
  @@ -243,46 +289,6 @@
               return $_[0];
           }
       }
  -}
  -
  -# compare any two datastructures (must pass references for non-scalars)
  -# undef()'s are valid args
  -sub t_is_equal($$) {
  -    my ($a, $b) = @_;
  -    return 0 unless @_ == 2;
  -
  -    if (defined $a && defined $b) {
  -        my $ref_a = ref $a;
  -        my $ref_b = ref $b;
  -        if (!$ref_a && !$ref_b) {
  -            return $a eq $b;
  -        }
  -        elsif ($ref_a eq 'ARRAY' && $ref_b eq 'ARRAY') {
  -            return 0 unless @$a == @$b;
  -            for my $i (0..$#$a) {
  -                t_is_equal($a->[$i], $b->[$i]) || return 0;
  -            }
  -        }
  -        elsif ($ref_a eq 'HASH' && $ref_b eq 'HASH') {
  -            return 0 unless (keys %$a) == (keys %$b);
  -            for my $key (sort keys %$a) {
  -                return 0 unless exists $b->{$key};
  -                t_is_equal($a->{$key}, $b->{$key}) || return 0;
  -            }
  -        }
  -        elsif ($ref_a eq 'Regexp') {
  -            return $b =~ $a;
  -        }
  -        else {
  -            # try to compare the references
  -            return $a eq $b;
  -        }
  -    }
  -    else {
  -        # undef == undef! a valid test
  -        return (defined $a || defined $b) ? 0 : 1;
  -    }
  -    return 1;
   }
   
   my $banner_format = 
  
  
  
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic