Commit | Line | Data |
f233d283 |
1 | #!./perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | print "1..2\n"; |
7 | |
8 | package Foo; |
9 | |
10 | use overload; |
11 | |
12 | sub import |
13 | { |
14 | overload::constant 'integer' => sub { return shift; }; |
15 | } |
16 | |
17 | package main; |
18 | |
19 | BEGIN { $INC{'Foo.pm'} = "/lib/Foo.pm" } |
20 | |
21 | use Foo; |
22 | |
23 | my $result = eval "5+6"; |
24 | |
25 | my $error = $@; |
26 | |
27 | my $label = "No exception was thrown with an overload::constant 'integer' inside an eval."; |
28 | # TEST |
29 | if ($error eq "") |
30 | { |
31 | print "ok 1 - $label\n" |
32 | } |
33 | else |
34 | { |
35 | print "not ok 1 - $label\n"; |
36 | print "# Error is $error\n"; |
37 | } |
38 | |
39 | $label = "Correct solution"; |
40 | |
41 | if (!defined($result)) |
42 | { |
43 | $result = ""; |
44 | } |
45 | # TEST |
46 | if ($result eq 11) |
47 | { |
48 | print "ok 2 - $label\n"; |
49 | } |
50 | else |
51 | { |
52 | print "not ok 2 - $label\n"; |
53 | print "# Result is $result\n"; |
54 | } |
55 | |