httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestUtil.pm
Date Thu, 10 Jun 2004 13:14:36 GMT
geoff       2004/06/10 06:14:36

  Modified:    perl-framework/Apache-Test Changes
               perl-framework/Apache-Test/lib/Apache TestUtil.pm
  Log:
  switch the order of arguments in t_cmp() and t_is_equal() so that
  the order matches Test::More::is() and other Test::More functions.
  the new call is: t_cmp($received, $expected, $comment);  support
  for $expected as the first argument marked as deprecated and will
  be removed in the course of the next few release cycles.
  
  Revision  Changes    Path
  1.138     +7 -0      httpd-test/perl-framework/Apache-Test/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Changes,v
  retrieving revision 1.137
  retrieving revision 1.138
  diff -u -r1.137 -r1.138
  --- Changes	28 May 2004 02:07:35 -0000	1.137
  +++ Changes	10 Jun 2004 13:14:36 -0000	1.138
  @@ -8,6 +8,13 @@
   
   =item 1.12-dev
   
  +switch the order of arguments in t_cmp() and t_is_equal() so that
  +the order matches Test::More::is() and other Test::More functions.
  +the new call is: t_cmp($received, $expected, $comment);  support
  +for $expected as the first argument marked as deprecated and will
  +be removed in the course of the next few release cycles.
  +[Geoffrey Young]
  +
   add skip_reason() to Apache::Test, which provides a mechanism for
   user-specified skip messages [Geoffrey Young]
   
  
  
  
  1.40      +33 -11    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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- TestUtil.pm	2 Jun 2004 02:13:23 -0000	1.39
  +++ TestUtil.pm	10 Jun 2004 13:14:36 -0000	1.40
  @@ -59,6 +59,16 @@
       my ($a, $b) = @_;
       return 0 unless @_ == 2;
   
  +    # this was added in Apache::Test::VERSION 1.12 - remove deprecated
  +    # logic sometime around 1.15 or mid September, 2004.
  +    if (UNIVERSAL::isa($a, 'Regexp')) {
  +        my @warning = ("WARNING!!! t_is_equal() argument order has changed.",
  +                       "use of a regular expression as the first argument",
  +                       "is deprecated.  support will be removed soon.");
  +        t_debug(@warning);
  +        ($a, $b) = ($b, $a);
  +    }
  +
       if (defined $a && defined $b) {
           my $ref_a = ref $a;
           my $ref_b = ref $b;
  @@ -78,8 +88,8 @@
                   t_is_equal($a->{$key}, $b->{$key}) || return 0;
               }
           }
  -        elsif ($ref_a eq 'Regexp') {
  -            return $b =~ $a;
  +        elsif ($ref_b eq 'Regexp') {
  +            return $a =~ $b;
           }
           else {
               # try to compare the references
  @@ -97,13 +107,25 @@
   
   sub t_cmp ($$;$) {
       Carp::carp(join(":", (caller)[1..2]) . 
  -        ' usage: $res = t_cmp($expected, $received, [$comment])')
  +        ' usage: $res = t_cmp($received, $expected, [$comment])')
               if @_ < 2 || @_ > 3;
   
  +    my ($received, $expected) = @_;
  +
  +    # this was added in Apache::Test::VERSION 1.12 - remove deprecated
  +    # logic sometime around 1.15 or mid September, 2004.
  +    if (UNIVERSAL::isa($_[0], 'Regexp')) {
  +        my @warning = ("WARNING!!! t_cmp() argument order has changed.",
  +                       "use of a regular expression as the first argument",
  +                       "is deprecated.  support will be removed soon.");
  +        t_debug(@warning);
  +        ($received, $expected) = ($expected, $received);
  +    }
  +
       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($_[0], $_[1]);
  +    t_debug("received: " . struct_as_string(0, $received));
  +    t_debug("expected: " . struct_as_string(0, $expected));
  +    return t_is_equal($received, $expected);
   }
   
   # Essentially t_cmp, but on Win32, first converts pathnames
  @@ -405,7 +427,7 @@
   
   =item t_cmp()
   
  -  t_cmp($expected, $received, $comment);
  +  t_cmp($received, $expected, $comment);
   
   t_cmp() prints the values of I<$comment>, I<$expected> and
   I<$received>. e.g.:
  @@ -443,9 +465,9 @@
           "hash of array of hashes");
   
   You can also compare the second argument against the first as a
  -regex. Use the C<qr//> function in the first argument. For example:
  +regex. Use the C<qr//> function in the second argument. For example:
   
  -  t_cmp(qr/^abc/, "abcd", "regex compare");
  +  t_cmp("abcd", qr/^abc/, "regex compare");
   
   will do:
   
  @@ -584,10 +606,10 @@
   hashes, arrays, scalars, undefs or a combination of any of these.  See
   t_cmp() for an example.
   
  -If C<$a> is a regex reference, the regex comparison C<$b =~ $a> is
  +If C<$b> is a regex reference, the regex comparison C<$a =~ $b> is
   performed. For example:
   
  -  t_is_equal(qr{^Apache}, $server_version);
  +  t_is_equal($server_version, qr{^Apache});
   
   If comparing non-scalars make sure to pass the references to the
   datastructures.
  
  
  

Mime
View raw message