summaryrefslogtreecommitdiff
path: root/t/op/defins.t
blob: 9e714a718bc19bde9bf730dc3a6fd7497d3918d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!./perl -w

#
# test auto defined() test insertion
#

BEGIN {
    chdir 't' if -d 't';
    unshift @INC, '../lib';
    $SIG{__WARN__} = sub { $warns++; warn $_[0] };
    print "1..14\n";
}

$wanted_filename = $^O eq 'VMS' ? '0.' : '0';
    
print "not " if $warns;
print "ok 1\n";

open(FILE,">./0");
print FILE "1\n";
print FILE "0";
close(FILE);

open(FILE,"<./0");
my $seen = 0;
my $dummy;
while (my $name = <FILE>)
 {
  $seen++ if $name eq '0';
 }            
print "not " unless $seen;
print "ok 2\n";

seek(FILE,0,0);
$seen = 0;
my $line = '';
do 
 {
  $seen++ if $line eq '0';
 } while ($line = <FILE>);

print "not " unless $seen;
print "ok 3\n";


seek(FILE,0,0);
$seen = 0;    
while (($seen ? $dummy : $name) = <FILE>)
 {
  $seen++ if $name eq '0';
 }
print "not " unless $seen;
print "ok 4\n";

seek(FILE,0,0);
$seen = 0;    
my %where;    
while ($where{$seen} = <FILE>)
 {
  $seen++ if $where{$seen} eq '0';
 }
print "not " unless $seen;
print "ok 5\n";
close FILE;

opendir(DIR,'.');
$seen = 0;
while (my $name = readdir(DIR))
 {
  $seen++ if $name eq $wanted_filename;
 }            
print "not " unless $seen;
print "ok 6\n";

rewinddir(DIR);
$seen = 0;    
$dummy = '';
while (($seen ? $dummy : $name) = readdir(DIR))
 {
  $seen++ if $name eq $wanted_filename;
 }
print "not " unless $seen;
print "ok 7\n";

rewinddir(DIR);
$seen = 0;    
while ($where{$seen} = readdir(DIR))
 {
  $seen++ if $where{$seen} eq $wanted_filename;
 }
print "not " unless $seen;
print "ok 8\n";

$seen = 0;
while (my $name = glob('*'))
 {
  $seen++ if $name eq $wanted_filename;
 }            
print "not " unless $seen;
print "ok 9\n";

$seen = 0;    
$dummy = '';
while (($seen ? $dummy : $name) = glob('*'))
 {
  $seen++ if $name eq $wanted_filename;
 }
print "not " unless $seen;
print "ok 10\n";

$seen = 0;    
while ($where{$seen} = glob('*'))
 {
  $seen++ if $where{$seen} eq $wanted_filename;
 }
print "not " unless $seen;
print "ok 11\n";

unlink("./0");

my %hash = (0 => 1, 1 => 2);

$seen = 0;
while (my $name = each %hash)
 {
  $seen++ if $name eq '0';
 }            
print "not " unless $seen;
print "ok 12\n";

$seen = 0;    
$dummy = '';
while (($seen ? $dummy : $name) = each %hash)
 {
  $seen++ if $name eq '0';
 }
print "not " unless $seen;
print "ok 13\n";

$seen = 0;    
while ($where{$seen} = each %hash)
 {
  $seen++ if $where{$seen} eq '0';
 }
print "not " unless $seen;
print "ok 14\n";