This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Cleanup and $. check
[perl5.git] / t / comp / multiline.t
CommitLineData
8d063cd8
LW
1#!./perl
2
7bbfeec9
MS
3BEGIN: {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8d063cd8 8
7bbfeec9 9plan(tests => 6);
8d063cd8 10
7bbfeec9 11open(TRY,'>Comp.try') || (die "Can't open temp file.");
8d063cd8
LW
12
13$x = 'now is the time
14for all good men
15to come to.
c6f14548
GS
16
17
18!
19
8d063cd8
LW
20';
21
22$y = 'now is the time' . "\n" .
23'for all good men' . "\n" .
c6f14548 24'to come to.' . "\n\n\n!\n\n";
8d063cd8 25
7bbfeec9 26is($x, $y, 'test data is sane');
8d063cd8 27
7bbfeec9
MS
28print TRY $x;
29close TRY;
8d063cd8 30
7bbfeec9 31open(TRY,'Comp.try') || (die "Can't reopen temp file.");
8d063cd8
LW
32$count = 0;
33$z = '';
7bbfeec9 34while (<TRY>) {
8d063cd8
LW
35 $z .= $_;
36 $count = $count + 1;
37}
38
7bbfeec9 39is($z, $y, 'basic multiline reading');
8d063cd8 40
7bbfeec9
MS
41is($count, 7, ' line count');
42is($., 7, ' $.' );
8d063cd8 43
7bbfeec9 44$out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type Comp.try`
95e8664e
CN
45 : ($^O eq 'MacOS') ? `catenate Comp.try`
46 : `cat Comp.try`;
8d063cd8 47
7bbfeec9 48like($out, qr/.*\n.*\n.*\n$/);
bbad3607 49
7bbfeec9 50close(TRY) || (die "Can't close temp file.");
a0d0e21e 51unlink 'Comp.try' || `/bin/rm -f Comp.try`;
8d063cd8 52
7bbfeec9 53is($out, $y);