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