This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Patch to JPL example program
[perl5.git] / t / pragma / warn / pp_sys
CommitLineData
599cee73
PM
1 pp_sys.c AOK
2
3 untie attempted while %d inner references still exist
4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
af8c498a 6 Filehandle %s opened only for input
599cee73
PM
7 format STDIN =
8 .
9 write STDIN;
10
af8c498a 11 Write on closed filehandle %s
599cee73
PM
12 format STDIN =
13 .
14 close STDIN;
15 write STDIN ;
16
17 page overflow
18
19 Filehandle %s never opened
20 $a = "abc"; printf $a "fred"
21
22 Filehandle %s opened only for input
23 $a = "abc";
24 printf $a "fred"
25
26 printf on closed filehandle %s
27 close STDIN ;
28 printf STDIN "fred"
29
30 Syswrite on closed filehandle
31 close STDIN;
32 syswrite STDIN, "fred", 1;
33
34 Send on closed socket
35 close STDIN;
36 send STDIN, "fred", 1
37
38 bind() on closed fd
39 close STDIN;
40 bind STDIN, "fred" ;
41
42
43 connect() on closed fd
44 close STDIN;
45 connect STDIN, "fred" ;
46
47 listen() on closed fd
48 close STDIN;
49 listen STDIN, 2;
50
51 accept() on closed fd
52 close STDIN;
53 accept STDIN, "fred" ;
54
55 shutdown() on closed fd
56 close STDIN;
57 shutdown STDIN, 0;
58
59 [gs]etsockopt() on closed fd
60 close STDIN;
61 setsockopt STDIN, 1,2,3;
62 getsockopt STDIN, 1,2;
63
64 get{sock, peer}name() on closed fd
65 close STDIN;
66 getsockname STDIN;
67 getpeername STDIN;
68
69 warn(warn_nl, "stat");
70
71 Test on unopened file <%s>
72 close STDIN ; -T STDIN ;
73
74 warn(warn_nl, "open");
75 -T "abc\ndef" ;
76
77
78
79__END__
80# pp_sys.c
81use warning 'untie' ;
82sub TIESCALAR { bless [] } ;
83$b = tie $a, 'main';
84untie $a ;
85EXPECT
86untie attempted while 1 inner references still exist at - line 5.
87########
88# pp_sys.c
89use warning 'io' ;
90format STDIN =
91.
92write STDIN;
93EXPECT
af8c498a 94Filehandle main::STDIN opened only for input at - line 5.
599cee73
PM
95########
96# pp_sys.c
97use warning 'closed' ;
98format STDIN =
99.
100close STDIN;
101write STDIN;
102EXPECT
af8c498a 103Write on closed filehandle main::STDIN at - line 6.
599cee73
PM
104########
105# pp_sys.c
106use warning 'io' ;
107format STDOUT_TOP =
108abc
109.
110format STDOUT =
111def
112ghi
113.
114$= = 1 ;
115$- =1 ;
3eeba6fb 116open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73
PM
117write ;
118EXPECT
119page overflow at - line 13.
120########
121# pp_sys.c
122use warning 'unopened' ;
123$a = "abc";
124printf $a "fred"
125EXPECT
126Filehandle main::abc never opened at - line 4.
127########
128# pp_sys.c
129use warning 'closed' ;
130close STDIN ;
131printf STDIN "fred"
132EXPECT
133printf on closed filehandle main::STDIN at - line 4.
134########
135# pp_sys.c
136use warning 'io' ;
137printf STDIN "fred"
138EXPECT
139Filehandle main::STDIN opened only for input at - line 3.
140########
141# pp_sys.c
142use warning 'closed' ;
143close STDIN;
144syswrite STDIN, "fred", 1;
145EXPECT
146Syswrite on closed filehandle at - line 4.
147########
148# pp_sys.c
149use warning 'io' ;
150use Config;
151BEGIN {
152 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
153 print <<EOM ;
154SKIPPED
155# send not present
156# bind not present
157# connect not present
158# accept not present
159# shutdown not present
160# setsockopt not present
161# getsockopt not present
162# getsockname not present
163# getpeername not present
164EOM
165 exit ;
166 }
167}
168close STDIN;
169send STDIN, "fred", 1;
170bind STDIN, "fred" ;
171connect STDIN, "fred" ;
172listen STDIN, 2;
173accept STDIN, "fred" ;
174shutdown STDIN, 0;
175setsockopt STDIN, 1,2,3;
176getsockopt STDIN, 1,2;
177getsockname STDIN;
178getpeername STDIN;
179EXPECT
180Send on closed socket at - line 22.
181bind() on closed fd at - line 23.
182connect() on closed fd at - line 24.
183listen() on closed fd at - line 25.
184accept() on closed fd at - line 26.
185shutdown() on closed fd at - line 27.
186[gs]etsockopt() on closed fd at - line 28.
187[gs]etsockopt() on closed fd at - line 29.
188get{sock, peer}name() on closed fd at - line 30.
189get{sock, peer}name() on closed fd at - line 31.
190########
191# pp_sys.c
192use warning 'newline' ;
193stat "abc\ndef";
194EXPECT
195Unsuccessful stat on filename containing newline at - line 3.
196########
197# pp_sys.c
198use warning 'unopened' ;
199close STDIN ;
200-T STDIN ;
201EXPECT
202Test on unopened file <STDIN> at - line 4.
203########
204# pp_sys.c
205use warning 'newline' ;
206-T "abc\ndef" ;
207EXPECT
208Unsuccessful open on filename containing newline at - line 3.