10 print defined($a) ? "not ok 1\n" : "ok 1\n";
13 print defined($a) ? "ok 2\n" : "not ok 2\n";
16 print defined($a) ? "not ok 3\n" : "ok 3\n";
19 print defined($a) ? "ok 4\n" : "not ok 4\n";
22 print defined($a) ? "not ok 5\n" : "ok 5\n";
26 print defined($a) ? "ok 6\n" : "not ok 6\n";
28 print defined($a) ? "not ok 7\n" : "ok 7\n";
32 print defined($a) ? "ok 8\n" : "not ok 8\n";
34 print defined($a) ? "not ok 9\n" : "ok 9\n";
37 print defined($ary{'foo'}) ? "ok 10\n" : "not ok 10\n";
38 print defined($ary{'bar'}) ? "not ok 11\n" : "ok 11\n";
40 print defined($ary{'foo'}) ? "not ok 12\n" : "ok 12\n";
42 print defined(@ary) ? "ok 13\n" : "not ok 13\n";
43 print defined(%ary) ? "ok 14\n" : "not ok 14\n";
45 print defined(@ary) ? "not ok 15\n" : "ok 15\n";
47 print defined(%ary) ? "not ok 16\n" : "ok 16\n";
49 print defined @ary ? "ok 17\n" : "not ok 17\n";
51 print defined %ary ? "ok 18\n" : "not ok 18\n";
53 sub foo { print "ok 19\n"; }
55 &foo || print "not ok 19\n";
57 print defined &foo ? "ok 20\n" : "not ok 20\n";
59 print defined(&foo) ? "not ok 21\n" : "ok 21\n";
62 print $@ =~ /^Modification of a read/ ? "ok 22\n" : "not ok 22\n";
65 print $@ =~ /^Modification of a read/ ? "ok 23\n" : "not ok 23\n";
69 tie my %foo, 'Tie::StdHash';
70 print defined %foo ? "ok 24\n" : "not ok 24\n";
72 print defined %foo ? "ok 25\n" : "not ok 25\n";
77 tie my @foo, 'Tie::StdArray';
78 print defined @foo ? "ok 26\n" : "not ok 26\n";
80 print defined @foo ? "ok 27\n" : "not ok 27\n";
84 # [perl #17753] segfault when undef'ing unquoted string constant
86 print $@ =~ /^Can't modify constant item/ ? "ok 28\n" : "not ok 28\n";
90 # undefing a hash may free objects with destructors that then try to
91 # modify the hash. To them, the hash should appear empty.
95 key1 => bless({}, 'X'),
96 key2 => bless({}, 'X'),
100 print "not " if keys %hash; print "ok $test\n"; $test++;
101 print "not " if values %hash; print "ok $test\n"; $test++;
102 print "not " if each %hash; print "ok $test\n"; $test++;
103 print "not " if defined delete $hash{'key2'}; print "ok $test\n"; $test++;