This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 3.0: (no announcement message available)
[perl5.git] / t / op.undef
CommitLineData
a687059c
LW
1#!./perl
2
3# $Header: op.undef,v 3.0 89/10/18 15:32:01 lwall Locked $
4
5print "1..21\n";
6
7print defined($a) ? "not ok 1\n" : "ok 1\n";
8
9$a = 1+1;
10print defined($a) ? "ok 2\n" : "not ok 2\n";
11
12undef $a;
13print defined($a) ? "not ok 3\n" : "ok 3\n";
14
15$a = "hi";
16print defined($a) ? "ok 4\n" : "not ok 4\n";
17
18$a = $b;
19print defined($a) ? "not ok 5\n" : "ok 5\n";
20
21@ary = ("1arg");
22$a = pop(@ary);
23print defined($a) ? "ok 6\n" : "not ok 6\n";
24$a = pop(@ary);
25print defined($a) ? "not ok 7\n" : "ok 7\n";
26
27@ary = ("1arg");
28$a = shift(@ary);
29print defined($a) ? "ok 8\n" : "not ok 8\n";
30$a = shift(@ary);
31print defined($a) ? "not ok 9\n" : "ok 9\n";
32
33$ary{'foo'} = 'hi';
34print defined($ary{'foo'}) ? "ok 10\n" : "not ok 10\n";
35print defined($ary{'bar'}) ? "not ok 11\n" : "ok 11\n";
36undef $ary{'foo'};
37print defined($ary{'foo'}) ? "not ok 12\n" : "ok 12\n";
38
39print defined(@ary) ? "ok 13\n" : "not ok 13\n";
40print defined(%ary) ? "ok 14\n" : "not ok 14\n";
41undef @ary;
42print defined(@ary) ? "not ok 15\n" : "ok 15\n";
43undef %ary;
44print defined(%ary) ? "not ok 16\n" : "ok 16\n";
45@ary = (1);
46print defined @ary ? "ok 17\n" : "not ok 18\n";
47%ary = (1,1);
48print defined %ary ? "ok 18\n" : "not ok 18\n";
49
50sub foo { print "ok 19\n"; }
51
52&foo || print "not ok 19\n";
53
54print defined &foo ? "ok 20\n" : "not ok 20\n";
55undef &foo;
56print defined(&foo) ? "not ok 21\n" : "ok 21\n";