4 # test auto defined() test insertion
10 $SIG{__WARN__} = sub { $warns++; warn $_[0] };
18 # We have to know if VMS is in UNIX mode. In UNIX mode, trailing dots
19 # should not be present. There are actually two settings that control this.
24 if (eval 'require VMS::Feature') {
25 $unix_rpt = VMS::Feature::current('filename_unix_report');
26 $drop_dot = VMS::Feature::current('readdir_dropdotnotype');
28 my $unix_report = $ENV{'DECC$FILENAME_UNIX_REPORT'} || '';
29 $unix_rpt = $unix_report =~ /^[ET1]/i;
30 my $drop_dot_notype = $ENV{'DECC$READDIR_DROPDOTNOTYPE'} || '';
31 $drop_dot = $drop_dot_notype =~ /^[ET1]/i;
33 $unix_mode = 1 if $drop_dot && unix_rpt;
36 # $wanted_filename should be 0 for readdir() and glob() tests.
37 # This is because it is the only valid filename that is false in a boolean test.
40 # print "hi\n" if $filename; # doesn't print
42 # In the case of VMS, '0' isn't always the filename that you get.
43 # Which makes those particular tests pointless.
45 $wanted_filename = $unix_mode ? '0' : '0.';
46 $saved_filename = './0';
48 cmp_ok($warns,'==',0,'no warns at start');
50 ok(open(FILE,">$saved_filename"),'created work file');
55 open(FILE,"<$saved_filename");
56 ok(defined(FILE),'opened work file');
59 while (my $name = <FILE>)
61 $seen++ if $name eq '0';
63 cmp_ok($seen,'==',1,'seen in while()');
70 $seen++ if $line eq '0';
71 } while ($line = <FILE>);
72 cmp_ok($seen,'==',1,'seen in do/while');
76 while (($seen ? $dummy : $name) = <FILE> )
78 $seen++ if $name eq '0';
80 cmp_ok($seen,'==',1,'seen in while() ternary');
85 while ($where{$seen} = <FILE>)
87 $seen++ if $where{$seen} eq '0';
89 cmp_ok($seen,'==',1,'seen in hash while()');
93 ok(defined(DIR),'opened current directory');
95 while (my $name = readdir(DIR))
97 $seen++ if $name eq $wanted_filename;
99 cmp_ok($seen,'==',1,'saw work file once');
104 while (($seen ? $dummy : $name) = readdir(DIR))
106 $seen++ if $name eq $wanted_filename;
108 cmp_ok($seen,'>',0,'saw file in while() ternary');
112 while ($where{$seen} = readdir(DIR))
114 $seen++ if $where{$seen} eq $wanted_filename;
116 cmp_ok($seen,'==',1,'saw file in hash while()');
123 $seen++ if $_ eq $wanted_filename;
125 cmp_ok($seen,'==',1,'saw file in bare while(readdir){...}');
131 $_ eq $wanted_filename && $seen++ while readdir(DIR);
132 cmp_ok($seen,'==',1,'saw file in bare "... while readdir"');
136 $_ = ""; # suppress uninit warning
139 $seen++ if $_ eq $wanted_filename;
140 } while (readdir(DIR));
141 cmp_ok($seen,'==',1,'saw file in bare do{...}while(readdir)');
144 while (my $name = glob('*'))
146 $seen++ if $name eq $wanted_filename;
148 cmp_ok($seen,'==',1,'saw file in glob while()');
152 while (($seen ? $dummy : $name) = glob('*'))
154 $seen++ if $name eq $wanted_filename;
156 cmp_ok($seen,'>',0,'saw file in glob hash while() ternary');
159 while ($where{$seen} = glob('*'))
161 $seen++ if $where{$seen} eq $wanted_filename;
163 cmp_ok($seen,'==',1,'seen in glob hash while()');
165 unlink($saved_filename);
166 ok(!(-f $saved_filename),'work file unlinked');
168 my %hash = (0 => 1, 1 => 2);
172 while (my $name = each %hash)
174 $seen++ if $name eq '0';
176 cmp_ok($seen,'==',1,'seen in each');
180 while (($seen ? $dummy : $name) = each %hash)
182 $seen++ if $name eq '0';
184 cmp_ok($seen,'==',1,'seen in each ternary');
187 while ($where{$seen} = each %hash)
189 $seen++ if $where{$seen} eq '0';
191 cmp_ok($seen,'==',1,'seen in each hash');
197 $seen++ if $_ eq '0';
199 cmp_ok($seen,'==',1,'0 seen in $_ in while(each %hash)');
205 $seen++ if $_ eq '0';
207 cmp_ok($seen,'==',1,'0 seen in $_ in while(each @array)');
211 $_ eq '0' and $seen++ while each %hash;
212 cmp_ok($seen,'==',1,'0 seen in $_ in while(each %hash) as stm mod');
216 $_ eq '0' and $seen++ while each @array;
217 cmp_ok($seen,'==',1,'0 seen in $_ in while(each @array) as stm mod');
219 cmp_ok($warns,'==',0,'no warns at finish');