10 my $CAT = ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') ? 'type'
11 : ($^O eq 'MacOS') ? 'catenate'
26 now @<<the@>>>> for all@|||||men to come @<<<<
28 'i' . 's', "time\n", $good, 'to'
32 open(OUT, '>Op_write.tmp') || die "Can't create Op_write.tmp";
36 $multiline = "forescore\nand\nseven years\n";
37 $foo = 'when in the course of human events it becomes necessary';
39 close OUT or die "Could not close: $!";
50 now is the time for all good men to come to\n";
52 if (`$CAT Op_write.tmp` eq $right)
53 { print "ok 1\n"; 1 while unlink 'Op_write.tmp'; }
55 { print "not ok 1\n"; }
58 my $fox = 'foxiness'; # Test a lexical variable.
68 now @<<the@>>>> for all@|||||men to come @<<<<
69 'i' . 's', "time\n", $good, 'to'
72 open OUT2, '>Op_write.tmp' or die "Can't create Op_write.tmp";
75 $multiline = "forescore\nand\nseven years\n";
76 $foo = 'when in the course of human events it becomes necessary';
78 close OUT2 or die "Could not close: $!";
92 now is the time for all good men to come to\n";
94 if (`$CAT Op_write.tmp` eq $right)
95 { print "ok 2\n"; 1 while unlink 'Op_write.tmp'; }
97 { print "not ok 2\n"; }
109 now @<<the@>>>> for all@|||||men to come @<<<<
110 'i' . 's', "time\n", $good, 'to'
114 open(OUT2, '>Op_write.tmp') || die "Can't create Op_write.tmp";
118 $multiline = "forescore\nand\nseven years\n";
119 $foo = 'when in the course of human events it becomes necessary';
121 close OUT2 or die "Could not close: $!";
136 now is the time for all good men to come to\n";
138 if (`$CAT Op_write.tmp` eq $right)
139 { print "ok 3\n"; 1 while unlink 'Op_write.tmp'; }
141 { print "not ok 3\n"; }
163 my $format1 = '@' . '>' x $_;
164 formline $format1, 'abc';
165 $was1 .= "$format1 $^A\n";
168 local $format2 = '@' . '>' x $_;
169 formline $format2, 'abc';
170 $was2 .= "$format2 $^A\n";
172 print $was1 eq $mustbe ? "ok 4\n" : "not ok 4\n";
173 print $was2 eq $mustbe ? "ok 5\n" : "not ok 5\n";
184 open(OUT3, '>Op_write.tmp') || die "Can't create Op_write.tmp";
188 close OUT3 or die "Could not close: $!";
193 if (`$CAT Op_write.tmp` eq $right)
194 { print "ok 6\n"; 1 while unlink 'Op_write.tmp'; }
196 { print "not ok 6\n"; }
198 # test lexicals and globals
206 open(LEX, ">&STDOUT") or die;
210 close LEX or die "Could not close: $!";
212 # LEX_INTERPNORMAL test
218 open OUT4, ">Op_write.tmp" or die "Can't create Op_write.tmp";
220 close OUT4 or die "Could not close: $!";
221 if (`$CAT Op_write.tmp` eq "1\n") {
223 1 while unlink "Op_write.tmp";
236 open(OUT10, '>Op_write.tmp') || die "Can't create Op_write.tmp";
240 close OUT10 or die "Could not close: $!";
242 $right = " 12.95 00012.95\n";
243 if (`$CAT Op_write.tmp` eq $right)
244 { print "ok 10\n"; 1 while unlink 'Op_write.tmp'; }
246 { print "not ok 10\n"; }
259 open(OUT11, '>Op_write.tmp') || die "Can't create Op_write.tmp";
263 close OUT11 or die "Could not close: $!";
269 if (`$CAT Op_write.tmp` eq $right)
270 { print "ok 11\n"; 1 while unlink 'Op_write.tmp'; }
272 { print "not ok 11\n"; }
274 # 12..44: scary format testing from Merijn H. Brand
276 if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' ||
277 ($^O eq 'os2' and not eval '$OS2::can_fork')) {
278 foreach (12..44) { print "ok $_ # skipped: '|-' and '-|' not supported\n"; }
282 use strict; # Amazed that this hackery can be made strict ...
284 # Just a complete test for format, including top-, left- and bottom marging
285 # and format detection through glob entries
287 $= = 7; # Page length
288 my $ps = $^L; $^L = ""; # Catch the page separator
289 my $tm = 1; # Top margin (empty lines before first output)
290 my $bm = 2; # Bottom marging (empty lines between last text and footer)
291 my $lm = 4; # Left margin (indent in spaces)
293 select ((select (STDOUT), $| = 1)[0]);
294 if ($lm > 0 and !open STDOUT, "|-") { # Left margin (in this test ALWAYS set)
295 select ((select (STDOUT), $| = 1)[0]);
300 print + ($_ eq <DATA> ? "" : "not "), "ok ", $i++, "\n";
303 print + (<DATA>?"not ":""), "ok ", $i++, "\n";
308 $= -= $bm + 1; # count one for the trailing "----"
321 $% == 1 and return "";
323 $lastmin < $= and print "\n" x $lastmin;
324 print "\n" x $bm, "----\n", $ps;
329 # Yes, this is sick ;-)
342 @{(shift @E)||["",""]}
352 exists $::{$fmt} or return 0;
353 $^O eq "MSWin32" or return defined *{$::{$fmt}}{FORMAT};
354 open my $null, "> /dev/null" or die;
355 my $fh = select $null;
362 $^ = has_format ("TOP") ? "TOP" : "EmptyTOP";
363 has_format ("ENTRY") or die "No format defined for ENTRY";
364 foreach my $e ( [ map { [ $_, "Test$_" ] } 1 .. 7 ],
365 [ map { [ $_, "${_}tseT" ] } 1 .. 5 ]) {
369 has_format ("EOR") or next;
373 if (has_format ("EOF")) {