This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] merge changes#922,944,949,965,970 from maintbranch
[perl5.git] / t / op / defins.t
CommitLineData
55d729e4
GS
1#!./perl -w
2
3#
4# test auto defined() test insertion
5#
6
7BEGIN {
8 chdir 't' if -d 't';
9 @INC = '../lib';
10 $SIG{__WARN__} = sub { $warns++; warn $_[0] };
11 print "1..14\n";
12}
13
14print "not " if $warns;
15print "ok 1\n";
16
17open(FILE,">./0");
18print FILE "1\n";
19print FILE "0";
20close(FILE);
21
22open(FILE,"<./0");
23my $seen = 0;
24my $dummy;
25while (my $name = <FILE>)
26 {
27 $seen++ if $name eq '0';
28 }
29print "not " unless $seen;
30print "ok 2\n";
31
32seek(FILE,0,0);
33$seen = 0;
34my $line = '';
35do
36 {
37 $seen++ if $line eq '0';
38 } while ($line = <FILE>);
39
40print "not " unless $seen;
41print "ok 3\n";
42
43
44seek(FILE,0,0);
45$seen = 0;
46while (($seen ? $dummy : $name) = <FILE>)
47 {
48 $seen++ if $name eq '0';
49 }
50print "not " unless $seen;
51print "ok 4\n";
52
53seek(FILE,0,0);
54$seen = 0;
55my %where;
56while ($where{$seen} = <FILE>)
57 {
58 $seen++ if $where{$seen} eq '0';
59 }
60print "not " unless $seen;
61print "ok 5\n";
62
63opendir(DIR,'.');
64$seen = 0;
65while (my $name = readdir(DIR))
66 {
67 $seen++ if $name eq '0';
68 }
69print "not " unless $seen;
70print "ok 6\n";
71
72rewinddir(DIR);
73$seen = 0;
74$dummy = '';
75while (($seen ? $dummy : $name) = readdir(DIR))
76 {
77 $seen++ if $name eq '0';
78 }
79print "not " unless $seen;
80print "ok 7\n";
81
82rewinddir(DIR);
83$seen = 0;
84while ($where{$seen} = readdir(DIR))
85 {
86 $seen++ if $where{$seen} eq '0';
87 }
88print "not " unless $seen;
89print "ok 8\n";
90
91$seen = 0;
92while (my $name = glob('*'))
93 {
94 $seen++ if $name eq '0';
95 }
96print "not " unless $seen;
97print "ok 9\n";
98
99$seen = 0;
100$dummy = '';
101while (($seen ? $dummy : $name) = glob('*'))
102 {
103 $seen++ if $name eq '0';
104 }
105print "not " unless $seen;
106print "ok 10\n";
107
108$seen = 0;
109while ($where{$seen} = glob('*'))
110 {
111 $seen++ if $where{$seen} eq '0';
112 }
113print "not " unless $seen;
114print "ok 11\n";
115
116unlink("./0");
117
118my %hash = (0 => 1, 1 => 2);
119
120$seen = 0;
121while (my $name = each %hash)
122 {
123 $seen++ if $name eq '0';
124 }
125print "not " unless $seen;
126print "ok 12\n";
127
128$seen = 0;
129$dummy = '';
130while (($seen ? $dummy : $name) = each %hash)
131 {
132 $seen++ if $name eq '0';
133 }
134print "not " unless $seen;
135print "ok 13\n";
136
137$seen = 0;
138while ($where{$seen} = each %hash)
139 {
140 $seen++ if $where{$seen} eq '0';
141 }
142print "not " unless $seen;
143print "ok 14\n";
144