Commit | Line | Data |
a687059c |
1 | #!./perl |
2 | |
e03bd546 |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
e03bd546 |
6 | } |
7 | |
659eaf73 |
8 | print "1..27\n"; |
a687059c |
9 | |
10 | print defined($a) ? "not ok 1\n" : "ok 1\n"; |
11 | |
12 | $a = 1+1; |
13 | print defined($a) ? "ok 2\n" : "not ok 2\n"; |
14 | |
15 | undef $a; |
16 | print defined($a) ? "not ok 3\n" : "ok 3\n"; |
17 | |
18 | $a = "hi"; |
19 | print defined($a) ? "ok 4\n" : "not ok 4\n"; |
20 | |
21 | $a = $b; |
22 | print defined($a) ? "not ok 5\n" : "ok 5\n"; |
23 | |
24 | @ary = ("1arg"); |
25 | $a = pop(@ary); |
26 | print defined($a) ? "ok 6\n" : "not ok 6\n"; |
27 | $a = pop(@ary); |
28 | print defined($a) ? "not ok 7\n" : "ok 7\n"; |
29 | |
30 | @ary = ("1arg"); |
31 | $a = shift(@ary); |
32 | print defined($a) ? "ok 8\n" : "not ok 8\n"; |
33 | $a = shift(@ary); |
34 | print defined($a) ? "not ok 9\n" : "ok 9\n"; |
35 | |
36 | $ary{'foo'} = 'hi'; |
37 | print defined($ary{'foo'}) ? "ok 10\n" : "not ok 10\n"; |
38 | print defined($ary{'bar'}) ? "not ok 11\n" : "ok 11\n"; |
39 | undef $ary{'foo'}; |
40 | print defined($ary{'foo'}) ? "not ok 12\n" : "ok 12\n"; |
41 | |
42 | print defined(@ary) ? "ok 13\n" : "not ok 13\n"; |
43 | print defined(%ary) ? "ok 14\n" : "not ok 14\n"; |
44 | undef @ary; |
45 | print defined(@ary) ? "not ok 15\n" : "ok 15\n"; |
46 | undef %ary; |
47 | print defined(%ary) ? "not ok 16\n" : "ok 16\n"; |
48 | @ary = (1); |
fe14fcc3 |
49 | print defined @ary ? "ok 17\n" : "not ok 17\n"; |
a687059c |
50 | %ary = (1,1); |
51 | print defined %ary ? "ok 18\n" : "not ok 18\n"; |
52 | |
53 | sub foo { print "ok 19\n"; } |
54 | |
55 | &foo || print "not ok 19\n"; |
56 | |
57 | print defined &foo ? "ok 20\n" : "not ok 20\n"; |
58 | undef &foo; |
59 | print defined(&foo) ? "not ok 21\n" : "ok 21\n"; |
a3f914c5 |
60 | |
61 | eval { undef $1 }; |
62 | print $@ =~ /^Modification of a read/ ? "ok 22\n" : "not ok 22\n"; |
63 | |
64 | eval { $1 = undef }; |
65 | print $@ =~ /^Modification of a read/ ? "ok 23\n" : "not ok 23\n"; |
66 | |
659eaf73 |
67 | { |
68 | require Tie::Hash; |
69 | tie my %foo, 'Tie::StdHash'; |
70 | print defined %foo ? "ok 24\n" : "not ok 24\n"; |
71 | %foo = ( a => 1 ); |
72 | print defined %foo ? "ok 25\n" : "not ok 25\n"; |
73 | } |
74 | |
75 | { |
76 | require Tie::Array; |
77 | tie my @foo, 'Tie::StdArray'; |
78 | print defined @foo ? "ok 26\n" : "not ok 26\n"; |
79 | @foo = ( a => 1 ); |
80 | print defined @foo ? "ok 27\n" : "not ok 27\n"; |
81 | } |