Commit | Line | Data |
66deed98 |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
66deed98 |
6 | } |
7 | |
c74f62b5 |
8 | use Test::More tests => 10; |
66deed98 |
9 | |
10 | BEGIN { $_ = 'foo'; } # because Symbol used to clobber $_ |
11 | |
12 | use Symbol; |
13 | |
c74f62b5 |
14 | ok( $_ eq 'foo', 'check $_ clobbering' ); |
66deed98 |
15 | |
16 | |
17 | # First test gensym() |
18 | $sym1 = gensym; |
c74f62b5 |
19 | ok( ref($sym1) eq 'GLOB', 'gensym() returns a GLOB' ); |
66deed98 |
20 | |
21 | $sym2 = gensym; |
22 | |
c74f62b5 |
23 | ok( $sym1 ne $sym2, 'gensym() returns a different GLOB' ); |
66deed98 |
24 | |
25 | ungensym $sym1; |
26 | |
27 | $sym1 = $sym2 = undef; |
28 | |
29 | |
30 | # Test qualify() |
31 | package foo; |
32 | |
33 | use Symbol qw(qualify); # must import into this package too |
34 | |
c74f62b5 |
35 | ::ok( qualify("x") eq "foo::x", 'qualify() with a simple identifier' ); |
36 | ::ok( qualify("x", "FOO") eq "FOO::x", 'qualify() with a package' ); |
37 | ::ok( qualify("BAR::x") eq "BAR::x", |
38 | 'qualify() with a qualified identifier' ); |
39 | ::ok( qualify("STDOUT") eq "main::STDOUT", |
40 | 'qualify() with a reserved identifier' ); |
41 | ::ok( qualify("ARGV", "FOO") eq "main::ARGV", |
42 | 'qualify() with a reserved identifier and a package' ); |
43 | ::ok( qualify("_foo") eq "foo::_foo", |
44 | 'qualify() with an identifier starting with a _' ); |
45 | ::ok( qualify("^FOO") eq "main::\cFOO", |
46 | 'qualify() with an identifier starting with a ^' ); |