File: symbolcache.t

package info (click to toggle)
perl 5.10.1-17squeeze6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 74,280 kB
  • ctags: 49,087
  • sloc: perl: 319,380; ansic: 193,238; sh: 37,981; pascal: 8,830; lisp: 7,515; cpp: 3,893; makefile: 2,375; xml: 1,972; yacc: 1,555
file content (42 lines) | stat: -rwxr-xr-x 1,082 bytes parent folder | download | duplicates (5)
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
#!./perl -w

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
    require './test.pl';
    plan( tests => 8 );
}

use strict;

# first, with delete
# simple removal
sub removed { 23 }
sub bound { removed() }
delete $main::{removed};
is( bound(), 23, 'function still bound' );
ok( !main->can('removed'), 'function not available as method' );

# replacement
sub replaced { 'func' }
is( replaced(), 'func', 'original function still bound' );
is( main->replaced, 'meth', 'method is replaced function' );
BEGIN { delete $main::{replaced} }
sub replaced { 'meth' }

# and now with undef
# simple removal
sub removed2 { 24 }
sub bound2 { removed2() }
undef $main::{removed2};
eval { bound2() };
like( $@, qr/Undefined subroutine &main::removed2 called/,
    'function not bound' );
ok( !main->can('removed2'), 'function not available as method' );

# replacement
sub replaced2 { 'func' }
is( replaced2(), 'meth', 'original function not bound, was replaced' );
ok( main->replaced2 eq 'meth', 'method is replaced function' );
BEGIN { undef $main::{replaced2} }
sub replaced2 { 'meth' }