Commit | Line | Data |
---|---|---|
55d729e4 GS |
1 | #!./perl -w |
2 | ||
3 | # | |
4 | # test auto defined() test insertion | |
5 | # | |
6 | ||
7 | BEGIN { | |
8 | chdir 't' if -d 't'; | |
93430cb4 | 9 | unshift @INC, '../lib'; |
55d729e4 GS |
10 | $SIG{__WARN__} = sub { $warns++; warn $_[0] }; |
11 | print "1..14\n"; | |
12 | } | |
b2b3adea HM |
13 | |
14 | $wanted_filename = $^O eq 'VMS' ? '0.' : '0'; | |
55d729e4 GS |
15 | |
16 | print "not " if $warns; | |
17 | print "ok 1\n"; | |
18 | ||
19 | open(FILE,">./0"); | |
20 | print FILE "1\n"; | |
21 | print FILE "0"; | |
22 | close(FILE); | |
23 | ||
24 | open(FILE,"<./0"); | |
25 | my $seen = 0; | |
26 | my $dummy; | |
27 | while (my $name = <FILE>) | |
28 | { | |
29 | $seen++ if $name eq '0'; | |
30 | } | |
31 | print "not " unless $seen; | |
32 | print "ok 2\n"; | |
33 | ||
34 | seek(FILE,0,0); | |
35 | $seen = 0; | |
36 | my $line = ''; | |
37 | do | |
38 | { | |
39 | $seen++ if $line eq '0'; | |
40 | } while ($line = <FILE>); | |
41 | ||
42 | print "not " unless $seen; | |
43 | print "ok 3\n"; | |
44 | ||
45 | ||
46 | seek(FILE,0,0); | |
47 | $seen = 0; | |
48 | while (($seen ? $dummy : $name) = <FILE>) | |
49 | { | |
50 | $seen++ if $name eq '0'; | |
51 | } | |
52 | print "not " unless $seen; | |
53 | print "ok 4\n"; | |
54 | ||
55 | seek(FILE,0,0); | |
56 | $seen = 0; | |
57 | my %where; | |
58 | while ($where{$seen} = <FILE>) | |
59 | { | |
60 | $seen++ if $where{$seen} eq '0'; | |
61 | } | |
62 | print "not " unless $seen; | |
63 | print "ok 5\n"; | |
7120fed6 | 64 | close FILE; |
55d729e4 GS |
65 | |
66 | opendir(DIR,'.'); | |
67 | $seen = 0; | |
68 | while (my $name = readdir(DIR)) | |
69 | { | |
b2b3adea | 70 | $seen++ if $name eq $wanted_filename; |
55d729e4 GS |
71 | } |
72 | print "not " unless $seen; | |
73 | print "ok 6\n"; | |
74 | ||
75 | rewinddir(DIR); | |
76 | $seen = 0; | |
77 | $dummy = ''; | |
78 | while (($seen ? $dummy : $name) = readdir(DIR)) | |
79 | { | |
b2b3adea | 80 | $seen++ if $name eq $wanted_filename; |
55d729e4 GS |
81 | } |
82 | print "not " unless $seen; | |
83 | print "ok 7\n"; | |
84 | ||
85 | rewinddir(DIR); | |
86 | $seen = 0; | |
87 | while ($where{$seen} = readdir(DIR)) | |
88 | { | |
b2b3adea | 89 | $seen++ if $where{$seen} eq $wanted_filename; |
55d729e4 GS |
90 | } |
91 | print "not " unless $seen; | |
92 | print "ok 8\n"; | |
93 | ||
94 | $seen = 0; | |
95 | while (my $name = glob('*')) | |
96 | { | |
b2b3adea | 97 | $seen++ if $name eq $wanted_filename; |
55d729e4 GS |
98 | } |
99 | print "not " unless $seen; | |
100 | print "ok 9\n"; | |
101 | ||
102 | $seen = 0; | |
103 | $dummy = ''; | |
104 | while (($seen ? $dummy : $name) = glob('*')) | |
105 | { | |
b2b3adea | 106 | $seen++ if $name eq $wanted_filename; |
55d729e4 GS |
107 | } |
108 | print "not " unless $seen; | |
109 | print "ok 10\n"; | |
110 | ||
111 | $seen = 0; | |
112 | while ($where{$seen} = glob('*')) | |
113 | { | |
b2b3adea | 114 | $seen++ if $where{$seen} eq $wanted_filename; |
55d729e4 GS |
115 | } |
116 | print "not " unless $seen; | |
117 | print "ok 11\n"; | |
118 | ||
119 | unlink("./0"); | |
120 | ||
121 | my %hash = (0 => 1, 1 => 2); | |
122 | ||
123 | $seen = 0; | |
124 | while (my $name = each %hash) | |
125 | { | |
126 | $seen++ if $name eq '0'; | |
127 | } | |
128 | print "not " unless $seen; | |
129 | print "ok 12\n"; | |
130 | ||
131 | $seen = 0; | |
132 | $dummy = ''; | |
133 | while (($seen ? $dummy : $name) = each %hash) | |
134 | { | |
135 | $seen++ if $name eq '0'; | |
136 | } | |
137 | print "not " unless $seen; | |
138 | print "ok 13\n"; | |
139 | ||
140 | $seen = 0; | |
141 | while ($where{$seen} = each %hash) | |
142 | { | |
143 | $seen++ if $where{$seen} eq '0'; | |
144 | } | |
145 | print "not " unless $seen; | |
146 | print "ok 14\n"; | |
147 |