diff options
author | Shlomi Fish <shlomif@vipe.technion.ac.il> | 2007-08-14 21:19:53 -0700 |
---|---|---|
committer | Abhijit Menon-Sen <ams@wiw.org> | 2007-08-18 08:03:28 +0000 |
commit | f233d283603b2a797a715547dc8cd2f426ef349f (patch) | |
tree | 00200fa83917f4545cace1fe7fb08ad92d23040b /t | |
parent | eee7770f948125835e9e241cf25412e5a30f14ff (diff) | |
download | perl-f233d283603b2a797a715547dc8cd2f426ef349f.tar.gz |
[perl #44647] [PATCH] Add a test for overload::constant 'integer' across use's.
Message-Id: <rt-3.6.HEAD-10743-1187176792-1816.44647-75-0@perl.org>
p4raw-id: //depot/perl@31732
Diffstat (limited to 't')
-rw-r--r-- | t/op/overload_integer.t | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/t/op/overload_integer.t b/t/op/overload_integer.t new file mode 100644 index 0000000000..073ac2a55c --- /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"; +} + |