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 open(FILE,">$saved_filename");
42 ok(defined(FILE),'created work file');
47 open(FILE,"<$saved_filename");
48 ok(defined(FILE),'opened work file');
51 while (my $name = <FILE>)
53 $seen++ if $name eq '0';
55 cmp_ok($seen,'==',1,'seen in while()');
62 $seen++ if $line eq '0';
63 } while ($line = <FILE>);
64 cmp_ok($seen,'==',1,'seen in do/while');
68 while (($seen ? $dummy : $name) = <FILE> )
70 $seen++ if $name eq '0';
72 cmp_ok($seen,'==',1,'seen in while() ternary');
77 while ($where{$seen} = <FILE>)
79 $seen++ if $where{$seen} eq '0';
81 cmp_ok($seen,'==',1,'seen in hash while()');
85 ok(defined(DIR),'opened current directory');
87 while (my $name = readdir(DIR))
89 $seen++ if $name eq $wanted_filename;
91 cmp_ok($seen,'==',1,'saw work file once');
96 while (($seen ? $dummy : $name) = readdir(DIR))
98 $seen++ if $name eq $wanted_filename;
100 cmp_ok($seen,'>',0,'saw file in while() ternary');
104 while ($where{$seen} = readdir(DIR))
106 $seen++ if $where{$seen} eq $wanted_filename;
108 cmp_ok($seen,'==',1,'saw file in hash while()');
111 while (my $name = glob('*'))
113 $seen++ if $name eq $wanted_filename;
115 cmp_ok($seen,'==',1,'saw file in glob while()');
119 while (($seen ? $dummy : $name) = glob('*'))
121 $seen++ if $name eq $wanted_filename;
123 cmp_ok($seen,'>',0,'saw file in glob hash while() ternary');
126 while ($where{$seen} = glob('*'))
128 $seen++ if $where{$seen} eq $wanted_filename;
130 cmp_ok($seen,'==',1,'seen in glob hash while()');
132 unlink($saved_filename);
133 ok(!(-f $saved_filename),'work file unlinked');
135 my %hash = (0 => 1, 1 => 2);
138 while (my $name = each %hash)
140 $seen++ if $name eq '0';
142 cmp_ok($seen,'==',1,'seen in each');
146 while (($seen ? $dummy : $name) = each %hash)
148 $seen++ if $name eq '0';
150 cmp_ok($seen,'==',1,'seen in each ternary');
153 while ($where{$seen} = each %hash)
155 $seen++ if $where{$seen} eq '0';
157 cmp_ok($seen,'==',1,'seen in each hash');
159 cmp_ok($warns,'==',0,'no warns at finish');