summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-11-08 22:06:31 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-08 22:06:31 +0000
commitb3c72391994409d4c0de25d67a0871d34a225923 (patch)
treedd42f85849734de4df265ff0eb33662c96f98f54
parente6c299c8c7a701ab02a228bf041af3efe6d81afb (diff)
downloadperl-b3c72391994409d4c0de25d67a0871d34a225923.tar.gz
Quote the variables in failures messages more nicely.
p4raw-id: //depot/perl@12907
-rw-r--r--t/test.pl14
1 files changed, 11 insertions, 3 deletions
diff --git a/t/test.pl b/t/test.pl
index 3a5db4d37f..eaf9d86544 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -72,12 +72,20 @@ sub ok {
_ok($pass, _where(), $name, @mess);
}
+sub _q {
+ my $x = shift;
+ return 'undef' unless defined $x;
+ my $q = $x;
+ $q =~ s/'/\\'/;
+ return "'$q'";
+}
+
sub is {
my ($got, $expected, $name, @mess) = @_;
my $pass = $got eq $expected;
unless ($pass) {
- unshift(@mess, "# got '$got'\n",
- "# expected '$expected'\n");
+ unshift(@mess, "# got "._q($got)."\n",
+ "# expected "._q($expected)."\n");
}
_ok($pass, _where(), $name, @mess);
}
@@ -86,7 +94,7 @@ sub isnt {
my ($got, $isnt, $name, @mess) = @_;
my $pass = $got ne $isnt;
unless( $pass ) {
- unshift(@mess, "# it should not be $got\n",
+ unshift(@mess, "# it should not be "._q($got)."\n",
"# but it is.\n");
}
_ok($pass, _where(), $name, @mess);