summaryrefslogtreecommitdiff
path: root/t/lib/overload_nomethod.t
blob: d72dceea10547184953637ee165a02a003cc2507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use warnings;
use strict;
use Test::Simple tests => 3;

package Foo;
use overload
  nomethod => sub { die "unimplemented\n" };
sub new { bless {}, shift };

package main;

my $foo = Foo->new;

eval {my $val = $foo + 1};
ok( $@ =~ /unimplemented/ );

eval {$foo += 1};
ok( $@ =~ /unimplemented/ );

eval {my $val = 0; $val += $foo};
ok( $@ =~ /unimplemented/ );