Stas Bekman wrote:
> +1

> +1

ok, here's a patch.  it warns when t_cmp() is used with a regex and the
arguments are not in the proper order.

the mod_perl test suite seems to run fine with it.

--Geoff
Index: lib/Apache/TestUtil.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestUtil.pm,v
retrieving revision 1.39
diff -u -r1.39 TestUtil.pm
--- lib/Apache/TestUtil.pm	2 Jun 2004 02:13:23 -0000	1.39
+++ lib/Apache/TestUtil.pm	8 Jun 2004 19:54:04 -0000
@@ -97,13 +97,23 @@
 
 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;
 
+    # this was added in Apache::Test::VERSION 1.12 - remove deprecated
+    # logic in 1.15.
+    if (UNIVERSAL::isa($_[0], 'Regexp')) {
+        my $warning = "WARNING!!! t_cmp() argument order has changed.\n" .
+                      "use of a regular expression as the first argument\n" .
+                      "is deprecated.  support will be removed soon.";
+        t_debug($warning);
+        ($_[0], $_[1]) = ($_[1], $_[0]);
+    }
+
     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, $_[0]));
+    t_debug("expected: " . struct_as_string(0, $_[1]));
+    return t_is_equal($_[1], $_[0]);
 }
 
 # Essentially t_cmp, but on Win32, first converts pathnames
@@ -405,7 +415,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 +453,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:
 

Reply via email to