[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 18:02:15
Message-ID: 20040412180215.14228.qmail () minotaur ! apache ! org
[Download RAW message or body]
stas 2004/04/12 11:02:15
Modified: perl-framework/Apache-Test/lib/Apache TestUtil.pm
Log:
explain how to handle undef values in t_cmp
Submitted by: William McKee <william@knowmad.com>
Revision Changes Path
1.35 +15 -0 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.34
retrieving revision 1.35
diff -u -u -r1.34 -r1.35
--- TestUtil.pm 9 Mar 2004 06:31:05 -0000 1.34
+++ TestUtil.pm 12 Apr 2004 18:02:15 -0000 1.35
@@ -433,6 +433,21 @@
"abcd" =~ /^abc/;
+When comparing to a return value from a function, that may return an
+C<undef> value, there is a catch -- in the list context the C<undef>
+value disappears and you end up comparing with the next argument.
+Therefore you can either explicitly call the function prior to
+comparison:
+
+ my $received = foo();
+ t_cmp($expected, $received, "may return undef")
+
+or use a scalar context:
+
+ t_cmp($expected, scalar(foo()), "may return undef")
+
+the parentheses for the C<scalar()>'s expression are mandatory here.
+
This function is exported by default.
=item t_debug()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic