This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove full stop in the 'try' feature heading
[perl5.git] / t / op / symbolcache.t
CommitLineData
446db2c1
RGS
1#!./perl -w
2
3BEGIN {
4 chdir 't' if -d 't';
446db2c1 5 require './test.pl';
624c42e2 6 set_up_inc('../lib');
446db2c1
RGS
7}
8
624c42e2
N
9plan( tests => 8 );
10
446db2c1
RGS
11use strict;
12
13# first, with delete
14# simple removal
15sub removed { 23 }
16sub bound { removed() }
17delete $main::{removed};
18is( bound(), 23, 'function still bound' );
19ok( !main->can('removed'), 'function not available as method' );
20
21# replacement
22sub replaced { 'func' }
23is( replaced(), 'func', 'original function still bound' );
24is( main->replaced, 'meth', 'method is replaced function' );
25BEGIN { delete $main::{replaced} }
26sub replaced { 'meth' }
27
28# and now with undef
29# simple removal
30sub removed2 { 24 }
31sub bound2 { removed2() }
a65cc145 32{ no strict; undef *{"removed2"} }
446db2c1
RGS
33eval { bound2() };
34like( $@, qr/Undefined subroutine &main::removed2 called/,
35 'function not bound' );
36ok( !main->can('removed2'), 'function not available as method' );
37
38# replacement
39sub replaced2 { 'func' }
40is( replaced2(), 'meth', 'original function not bound, was replaced' );
41ok( main->replaced2 eq 'meth', 'method is replaced function' );
42BEGIN { undef $main::{replaced2} }
43sub replaced2 { 'meth' }