From: Shlomi Fish Date: Wed, 15 Aug 2007 04:19:53 +0000 (-0700) Subject: [perl #44647] [PATCH] Add a test for overload::constant 'integer' across use's. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f233d283603b2a797a715547dc8cd2f426ef349f;p=p5sagit%2Fp5-mst-13.2.git [perl #44647] [PATCH] Add a test for overload::constant 'integer' across use's. Message-Id: p4raw-id: //depot/perl@31732 --- diff --git a/MANIFEST b/MANIFEST index b4d5ea0..38edcca 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3740,6 +3740,7 @@ t/op/oct.t See if oct and hex work t/op/ord.t See if ord works t/op/or.t See if || works in weird situations t/op/override.t See if operator overriding works +t/op/overload_integer.t See if overload::constant for integer works after "use". t/op/pack.t See if pack and unpack work t/op/pat.t See if esoteric patterns work t/op/pos.t See if pos works diff --git a/t/op/overload_integer.t b/t/op/overload_integer.t new file mode 100644 index 0000000..073ac2a --- /dev/null +++ b/t/op/overload_integer.t @@ -0,0 +1,55 @@ +#!./perl + +use strict; +use warnings; + +print "1..2\n"; + +package Foo; + +use overload; + +sub import +{ + overload::constant 'integer' => sub { return shift; }; +} + +package main; + +BEGIN { $INC{'Foo.pm'} = "/lib/Foo.pm" } + +use Foo; + +my $result = eval "5+6"; + +my $error = $@; + +my $label = "No exception was thrown with an overload::constant 'integer' inside an eval."; +# TEST +if ($error eq "") +{ + print "ok 1 - $label\n" +} +else +{ + print "not ok 1 - $label\n"; + print "# Error is $error\n"; +} + +$label = "Correct solution"; + +if (!defined($result)) +{ + $result = ""; +} +# TEST +if ($result eq 11) +{ + print "ok 2 - $label\n"; +} +else +{ + print "not ok 2 - $label\n"; + print "# Result is $result\n"; +} +