xref: /openbsd-src/gnu/usr.bin/perl/t/comp/decl.t (revision 48950c12d106c85f315112191a0228d7b83b9510)
14a4f25f9Sdownsj#!./perl
24a4f25f9Sdownsj
3*48950c12Ssthen# check to see if subroutine declarations work everywhere
44a4f25f9Sdownsj
54a4f25f9Sdownsjsub one {
64a4f25f9Sdownsj    print "ok 1\n";
74a4f25f9Sdownsj}
84a4f25f9Sdownsjformat one =
9*48950c12Ssthenok 6
104a4f25f9Sdownsj.
114a4f25f9Sdownsj
12*48950c12Ssthenprint "1..9\n";
134a4f25f9Sdownsj
140dc2eaceSmillertone();
150dc2eaceSmillerttwo();
164a4f25f9Sdownsj
174a4f25f9Sdownsjsub two {
184a4f25f9Sdownsj    print "ok 2\n";
194a4f25f9Sdownsj}
204a4f25f9Sdownsjformat two =
214a4f25f9Sdownsj@<<<
224a4f25f9Sdownsj$foo
234a4f25f9Sdownsj.
244a4f25f9Sdownsj
254a4f25f9Sdownsjif ($x eq $x) {
264a4f25f9Sdownsj    sub three {
274a4f25f9Sdownsj	print "ok 3\n";
284a4f25f9Sdownsj    }
290dc2eaceSmillert    three();
304a4f25f9Sdownsj}
314a4f25f9Sdownsj
320dc2eaceSmillertfour();
33*48950c12Ssthenfive();
344a4f25f9Sdownsj$~ = 'one';
354a4f25f9Sdownsjwrite;
364a4f25f9Sdownsj$~ = 'two';
37*48950c12Ssthen$foo = "ok 7";
384a4f25f9Sdownsjwrite;
394a4f25f9Sdownsj$~ = 'three';
404a4f25f9Sdownsjwrite;
414a4f25f9Sdownsj
424a4f25f9Sdownsjformat three =
43*48950c12Ssthenok 8
444a4f25f9Sdownsj.
454a4f25f9Sdownsj
46*48950c12Ssthenif ($x eq $x) {
47*48950c12Ssthen    goto quux;
48*48950c12Ssthen}
49*48950c12Ssthen
50*48950c12Ssthenprint "not ok 9\n";
51*48950c12Ssthenexit 1;
52*48950c12Ssthen
534a4f25f9Sdownsjsub four {
544a4f25f9Sdownsj    print "ok 4\n";
554a4f25f9Sdownsj}
56*48950c12Ssthen
57*48950c12Ssthenquux:
58*48950c12Ssthensub five {
59*48950c12Ssthen    print "ok 5\n";
60*48950c12Ssthen}
61*48950c12Ssthenprint "ok 9\n";
62