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