From: Rafael Garcia-Suarez Date: Fri, 2 Jan 2009 11:05:59 +0000 (+0100) Subject: Add a new test for overloading.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=abb619adf81df64d67e76aa14cbb224b1ad99bd6;p=p5sagit%2Fp5-mst-13.2.git Add a new test for overloading.pm This one overloads "cos", which is currently at the end of the overload table, so we properly test the bitstring stored in %^H --- diff --git a/lib/overloading.t b/lib/overloading.t index 8121cc8..cedfc51 100644 --- a/lib/overloading.t +++ b/lib/overloading.t @@ -7,7 +7,7 @@ BEGIN { BEGIN { require "./test.pl"; - plan(tests => 22); + plan(tests => 35); } use Scalar::Util qw(refaddr); @@ -19,6 +19,7 @@ use Scalar::Util qw(refaddr); fallback => 1, '""' => sub { "foo" }, '0+' => sub { 42 }, + cos => sub { "far side of overload table" }, ); sub new { bless {}, shift }; @@ -28,16 +29,19 @@ my $x = Stringifies->new; is( "$x", "foo", "stringifies" ); is( 0 + $x, 42, "numifies" ); +is( cos($x), "far side of overload table", "cosinusfies" ); { no overloading; is( "$x", overload::StrVal($x), "no stringification" ); 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( 0 + $x, refaddr($x), "no numification" ); + is( cos($x), cos(refaddr($x)), "no cosinusfication" ); } } @@ -46,37 +50,48 @@ is( 0 + $x, 42, "numifies" ); is( "$x", overload::StrVal($x), "no stringification" ); is( 0 + $x, 42, "numifies" ); + is( cos($x), "far side of overload table", "cosinusfies" ); { no overloading; is( "$x", overload::StrVal($x), "no stringification" ); is( 0 + $x, refaddr($x), "no numification" ); + is( cos($x), cos(refaddr($x)), "no cosinusfication" ); } use overloading '""'; is( "$x", "foo", "stringifies" ); is( 0 + $x, 42, "numifies" ); + is( cos($x), "far side of overload table", "cosinusfies" ); no overloading '0+'; is( "$x", "foo", "stringifies" ); 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( 0 + $x, refaddr($x), "no numification" ); + is( cos($x), "far side of overload table", "cosinusfies" ); { use overloading; is( "$x", "foo", "stringifies" ); is( 0 + $x, 42, "numifies" ); + is( cos($x), "far side of overload table", "cosinusfies" ); } } is( "$x", "foo", "stringifies" ); is( 0 + $x, refaddr($x), "no numification" ); + is( cos($x), "far side of overload table", "cosinusfies" ); + no overloading "cos"; + is( "$x", "foo", "stringifies" ); + is( 0 + $x, refaddr($x), "no numification" ); + is( cos($x), cos(refaddr($x)), "no cosinusfication" ); BEGIN { ok(exists($^H{overloading}), "overloading hint present") }