blob: 073ac2a55c18fd82bc2f06722eba2f5996bb2084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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";
}
|