summaryrefslogtreecommitdiff
path: root/lib/overloading.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-24 10:24:21 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-24 10:34:39 -0800
commita75c6ed6bbe8051aad5c980a7e52906076b66543 (patch)
tree5dd08c21fda93de08484d682673066da0836f4b5 /lib/overloading.t
parent8d5692911401401dd403c3c2aa0aa3eca63171a4 (diff)
downloadperl-a75c6ed6bbe8051aad5c980a7e52906076b66543.tar.gz
[perl #108780] Make ‘no overloading’ work with qr//
Traditionally, overload::StrVal(qr//) has returned Regexp=SCALAR(0xc0ffee), and later Regexp=REGEXP(0xc0c0a) when regexps were made into first-class SVs. When the overloading pragma was added in 5.10.1, qr// things were not accounted for, so they would still stringify as (?-xism:) even with ‘no overloading’ (or as (?^:) under 5.14). This commit makes the overloading pragma work with qr// things, so that they stringify the same way as overload::StrVal; i.e., as Regexp=REGEXP(0xbe600d).
Diffstat (limited to 'lib/overloading.t')
-rw-r--r--lib/overloading.t15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/overloading.t b/lib/overloading.t
index 2e1fb40ffc..787edb1b9d 100644
--- a/lib/overloading.t
+++ b/lib/overloading.t
@@ -1,6 +1,6 @@
#./perl
-use Test::More tests => 35;
+use Test::More tests => 46;
use Scalar::Util qw(refaddr);
@@ -18,20 +18,25 @@ use Scalar::Util qw(refaddr);
}
my $x = Stringifies->new;
+my $y = qr//;
+my $ystr = "$y";
is( "$x", "foo", "stringifies" );
+is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
no overloading;
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
{
no overloading '""';
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
}
@@ -41,12 +46,14 @@ is( cos($x), "far side of overload table", "cosinusfies" );
no overloading '""';
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
no overloading;
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
}
@@ -54,34 +61,40 @@ is( cos($x), "far side of overload table", "cosinusfies" );
use overloading '""';
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
no overloading '0+';
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
no overloading '""';
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
use overloading;
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
}
}
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), "far side of overload table", "cosinusfies" );
no overloading "cos";
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );