xref: /openbsd/gnu/usr.bin/perl/t/comp/multiline.t (revision 404b540a)
1#!./perl
2
3BEGIN {
4    chdir 't';
5    @INC = '../lib';
6    require './test.pl';
7}
8
9plan(tests => 6);
10
11my $filename = tempfile();
12open(TRY,'>',$filename) || (die "Can't open $filename: $!");
13
14$x = 'now is the time
15for all good men
16to come to.
17
18
19!
20
21';
22
23$y = 'now is the time' . "\n" .
24'for all good men' . "\n" .
25'to come to.' . "\n\n\n!\n\n";
26
27is($x, $y,  'test data is sane');
28
29print TRY $x;
30close TRY or die "Could not close: $!";
31
32open(TRY,$filename) || (die "Can't reopen $filename: $!");
33$count = 0;
34$z = '';
35while (<TRY>) {
36    $z .= $_;
37    $count = $count + 1;
38}
39
40is($z, $y,  'basic multiline reading');
41
42is($count, 7,   '    line count');
43is($., 7,       '    $.' );
44
45$out = (($^O eq 'MSWin32') || $^O eq 'NetWare') ? `type $filename`
46    : ($^O eq 'VMS') ? `type $filename.;0`   # otherwise .LIS is assumed
47    : ($^O eq 'MacOS') ? `catenate $filename`
48    : `cat $filename`;
49
50like($out, qr/.*\n.*\n.*\n$/);
51
52close(TRY) || (die "Can't close $filename: $!");
53
54is($out, $y);
55