This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
test that pp_leavesub copies returned PADTMPs.
[perl5.git] / t / op / overload_integer.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     push @INC, '../lib';
6     require './test.pl';
7 }
8
9 use strict;
10 use warnings;
11
12 plan tests => 2;
13
14 package Foo;
15
16 use overload; 
17
18 sub import
19 {
20     overload::constant 'integer' => sub { return shift };
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";
30 my $error = $@;
31 $result //= '';
32
33 is ($error, '', "No exception was thrown with an overload::constant 'integer' inside an eval.");
34 is ($result, 11, "Correct solution");
35