summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2002-09-06 07:03:16 -0700
committerhv <hv@crypt.org>2002-09-08 13:58:10 +0000
commitc831d34fb12f71d1bffb73fbcf1d43a945de63bd (patch)
tree5a1bbb9cd35163c8d2c1cc0e32aeb690b7ef900a
parent3905a40f663ceeef17285c01589b6dc9cce3fe88 (diff)
downloadperl-c831d34fb12f71d1bffb73fbcf1d43a945de63bd.tar.gz
Re: [PATCH t/test.pl] Let is/isnt() handle undef without warnings
Message-ID: <20020906210315.GC808@ool-18b93024.dyn.optonline.net> p4raw-id: //depot/perl@17861
-rw-r--r--t/test.pl22
1 files changed, 20 insertions, 2 deletions
diff --git a/t/test.pl b/t/test.pl
index 427a64f578..735d966533 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -133,7 +133,16 @@ sub display {
sub is {
my ($got, $expected, $name, @mess) = @_;
- my $pass = $got eq $expected;
+
+ my $pass;
+ if( !defined $got || !defined $expected ) {
+ # undef only matches undef
+ $pass = !defined $got && !defined $expected;
+ }
+ else {
+ $pass = $got eq $expected;
+ }
+
unless ($pass) {
unshift(@mess, "# got "._q($got)."\n",
"# expected "._q($expected)."\n");
@@ -143,7 +152,16 @@ sub is {
sub isnt {
my ($got, $isnt, $name, @mess) = @_;
- my $pass = $got ne $isnt;
+
+ my $pass;
+ if( !defined $got || !defined $isnt ) {
+ # undef only matches undef
+ $pass = defined $got || defined $isnt;
+ }
+ else {
+ $pass = $got ne $isnt;
+ }
+
unless( $pass ) {
unshift(@mess, "# it should not be "._q($got)."\n",
"# but it is.\n");