xref: /openbsd-src/gnu/usr.bin/perl/t/lib/overload_nomethod.t (revision 56d68f1e19ff848c889ecfa71d3a06340ff64892)
1*56d68f1eSafresh1#!./perl
2*56d68f1eSafresh1
3*56d68f1eSafresh1BEGIN {
4*56d68f1eSafresh1    chdir 't' if -d 't';
5*56d68f1eSafresh1    @INC = '../lib';
6*56d68f1eSafresh1    require './test.pl';
7*56d68f1eSafresh1}
8*56d68f1eSafresh1
9*56d68f1eSafresh1plan( tests => 3);
10898184e3Ssthenuse warnings;
11898184e3Ssthenuse strict;
12898184e3Ssthen
13898184e3Ssthenpackage Foo;
14898184e3Ssthenuse overload
15898184e3Ssthen  nomethod => sub { die "unimplemented\n" };
16898184e3Ssthensub new { bless {}, shift };
17898184e3Ssthen
18898184e3Ssthenpackage main;
19898184e3Ssthen
20898184e3Ssthenmy $foo = Foo->new;
21898184e3Ssthen
22898184e3Sstheneval {my $val = $foo + 1};
23b8851fccSafresh1ok( $@ =~ /unimplemented/, "'+'  not implemented; 'nomethod' special key invoked" );
24898184e3Ssthen
25898184e3Sstheneval {$foo += 1};
26b8851fccSafresh1ok( $@ =~ /unimplemented/, "'+=' not implemented; 'nomethod' special key invoked"  );
27898184e3Ssthen
28898184e3Sstheneval {my $val = 0; $val += $foo};
29b8851fccSafresh1ok( $@ =~ /unimplemented/, "'+=' not implemented; 'nomethod' special key invoked"  );
30898184e3Ssthen
31