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 = $unix_mode ? '0' : '0.';
37 $saved_filename = './0';
39 cmp_ok($warns,'==',0,'no warns at start');
41 ok(open(FILE,">$saved_filename"),'created work file');
46 open(FILE,"<$saved_filename");
47 ok(defined(FILE),'opened work file');
50 while (my $name = <FILE>)
52 $seen++ if $name eq '0';
54 cmp_ok($seen,'==',1,'seen in while()');
61 $seen++ if $line eq '0';
62 } while ($line = <FILE>);
63 cmp_ok($seen,'==',1,'seen in do/while');
67 while (($seen ? $dummy : $name) = <FILE> )
69 $seen++ if $name eq '0';
71 cmp_ok($seen,'==',1,'seen in while() ternary');
76 while ($where{$seen} = <FILE>)
78 $seen++ if $where{$seen} eq '0';
80 cmp_ok($seen,'==',1,'seen in hash while()');
84 ok(defined(DIR),'opened current directory');
86 while (my $name = readdir(DIR))
88 $seen++ if $name eq $wanted_filename;
90 cmp_ok($seen,'==',1,'saw work file once');
95 while (($seen ? $dummy : $name) = readdir(DIR))
97 $seen++ if $name eq $wanted_filename;
99 cmp_ok($seen,'>',0,'saw file in while() ternary');
103 while ($where{$seen} = readdir(DIR))
105 $seen++ if $where{$seen} eq $wanted_filename;
107 cmp_ok($seen,'==',1,'saw file in hash while()');
110 while (my $name = glob('*'))
112 $seen++ if $name eq $wanted_filename;
114 cmp_ok($seen,'==',1,'saw file in glob while()');
118 while (($seen ? $dummy : $name) = glob('*'))
120 $seen++ if $name eq $wanted_filename;
122 cmp_ok($seen,'>',0,'saw file in glob hash while() ternary');
125 while ($where{$seen} = glob('*'))
127 $seen++ if $where{$seen} eq $wanted_filename;
129 cmp_ok($seen,'==',1,'seen in glob hash while()');
131 unlink($saved_filename);
132 ok(!(-f $saved_filename),'work file unlinked');
134 my %hash = (0 => 1, 1 => 2);
137 while (my $name = each %hash)
139 $seen++ if $name eq '0';
141 cmp_ok($seen,'==',1,'seen in each');
145 while (($seen ? $dummy : $name) = each %hash)
147 $seen++ if $name eq '0';
149 cmp_ok($seen,'==',1,'seen in each ternary');
152 while ($where{$seen} = each %hash)
154 $seen++ if $where{$seen} eq '0';
156 cmp_ok($seen,'==',1,'seen in each hash');
158 cmp_ok($warns,'==',0,'no warns at finish');