Commit | Line | Data |
---|---|---|
f233d283 SF |
1 | #!./perl |
2 | ||
f9512aff CK |
3 | BEGIN { |
4 | chdir 't' if -d 't'; | |
5 | push @INC, '../lib'; | |
6 | require './test.pl'; | |
7 | } | |
8 | ||
f233d283 SF |
9 | use strict; |
10 | use warnings; | |
11 | ||
f9512aff | 12 | plan tests => 2; |
f233d283 SF |
13 | |
14 | package Foo; | |
15 | ||
16 | use overload; | |
17 | ||
18 | sub import | |
19 | { | |
f9512aff | 20 | overload::constant 'integer' => sub { return shift }; |
f233d283 SF |
21 | } |
22 | ||
23 | package main; | |
24 | ||
25 | BEGIN { $INC{'Foo.pm'} = "/lib/Foo.pm" } | |
26 | ||
27 | use Foo; | |
28 | ||
29 | my $result = eval "5+6"; | |
f233d283 | 30 | my $error = $@; |
f9512aff | 31 | $result //= ''; |
f233d283 | 32 | |
f9512aff CK |
33 | is ($error, '', "No exception was thrown with an overload::constant 'integer' inside an eval."); |
34 | is ($result, 11, "Correct solution"); | |
f233d283 | 35 |