1N/A#!./perl
1N/A
1N/ABEGIN {
1N/A chdir 't' if -d 't';
1N/A @INC = '../lib';
1N/A}
1N/A
1N/Aprint "1..36\n";
1N/A
1N/Aprint defined($a) ? "not ok 1\n" : "ok 1\n";
1N/A
1N/A$a = 1+1;
1N/Aprint defined($a) ? "ok 2\n" : "not ok 2\n";
1N/A
1N/Aundef $a;
1N/Aprint defined($a) ? "not ok 3\n" : "ok 3\n";
1N/A
1N/A$a = "hi";
1N/Aprint defined($a) ? "ok 4\n" : "not ok 4\n";
1N/A
1N/A$a = $b;
1N/Aprint defined($a) ? "not ok 5\n" : "ok 5\n";
1N/A
1N/A@ary = ("1arg");
1N/A$a = pop(@ary);
1N/Aprint defined($a) ? "ok 6\n" : "not ok 6\n";
1N/A$a = pop(@ary);
1N/Aprint defined($a) ? "not ok 7\n" : "ok 7\n";
1N/A
1N/A@ary = ("1arg");
1N/A$a = shift(@ary);
1N/Aprint defined($a) ? "ok 8\n" : "not ok 8\n";
1N/A$a = shift(@ary);
1N/Aprint defined($a) ? "not ok 9\n" : "ok 9\n";
1N/A
1N/A$ary{'foo'} = 'hi';
1N/Aprint defined($ary{'foo'}) ? "ok 10\n" : "not ok 10\n";
1N/Aprint defined($ary{'bar'}) ? "not ok 11\n" : "ok 11\n";
1N/Aundef $ary{'foo'};
1N/Aprint defined($ary{'foo'}) ? "not ok 12\n" : "ok 12\n";
1N/A
1N/Aprint defined(@ary) ? "ok 13\n" : "not ok 13\n";
1N/Aprint defined(%ary) ? "ok 14\n" : "not ok 14\n";
1N/Aundef @ary;
1N/Aprint defined(@ary) ? "not ok 15\n" : "ok 15\n";
1N/Aundef %ary;
1N/Aprint defined(%ary) ? "not ok 16\n" : "ok 16\n";
1N/A@ary = (1);
1N/Aprint defined @ary ? "ok 17\n" : "not ok 17\n";
1N/A%ary = (1,1);
1N/Aprint defined %ary ? "ok 18\n" : "not ok 18\n";
1N/A
1N/Asub foo { print "ok 19\n"; }
1N/A
1N/A&foo || print "not ok 19\n";
1N/A
1N/Aprint defined &foo ? "ok 20\n" : "not ok 20\n";
1N/Aundef &foo;
1N/Aprint defined(&foo) ? "not ok 21\n" : "ok 21\n";
1N/A
1N/Aeval { undef $1 };
1N/Aprint $@ =~ /^Modification of a read/ ? "ok 22\n" : "not ok 22\n";
1N/A
1N/Aeval { $1 = undef };
1N/Aprint $@ =~ /^Modification of a read/ ? "ok 23\n" : "not ok 23\n";
1N/A
1N/A{
1N/A require Tie::Hash;
1N/A tie my %foo, 'Tie::StdHash';
1N/A print defined %foo ? "ok 24\n" : "not ok 24\n";
1N/A %foo = ( a => 1 );
1N/A print defined %foo ? "ok 25\n" : "not ok 25\n";
1N/A}
1N/A
1N/A{
1N/A require Tie::Array;
1N/A tie my @foo, 'Tie::StdArray';
1N/A print defined @foo ? "ok 26\n" : "not ok 26\n";
1N/A @foo = ( a => 1 );
1N/A print defined @foo ? "ok 27\n" : "not ok 27\n";
1N/A}
1N/A
1N/A{
1N/A # [perl #17753] segfault when undef'ing unquoted string constant
1N/A eval 'undef tcp';
1N/A print $@ =~ /^Can't modify constant item/ ? "ok 28\n" : "not ok 28\n";
1N/A}
1N/A
1N/A# bugid 3096
1N/A# undefing a hash may free objects with destructors that then try to
1N/A# modify the hash. To them, the hash should appear empty.
1N/A
1N/A$test = 29;
1N/A%hash = (
1N/A key1 => bless({}, 'X'),
1N/A key2 => bless({}, 'X'),
1N/A);
1N/Aundef %hash;
1N/Asub X::DESTROY {
1N/A print "not " if keys %hash; print "ok $test\n"; $test++;
1N/A print "not " if values %hash; print "ok $test\n"; $test++;
1N/A print "not " if each %hash; print "ok $test\n"; $test++;
1N/A print "not " if defined delete $hash{'key2'}; print "ok $test\n"; $test++;
1N/A}