This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sync a bunch of files with Test::Simple 0.86
[perl5.git] / t / comp / multiline.t
CommitLineData
8d063cd8
LW
1#!./perl
2
853410bb 3BEGIN {
7bbfeec9
MS
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8d063cd8 8
7bbfeec9 9plan(tests => 6);
8d063cd8 10
2d90ac95
NC
11my $filename = tempfile();
12open(TRY,'>',$filename) || (die "Can't open $filename: $!");
8d063cd8
LW
13
14$x = 'now is the time
15for all good men
16to come to.
c6f14548
GS
17
18
19!
20
8d063cd8
LW
21';
22
23$y = 'now is the time' . "\n" .
24'for all good men' . "\n" .
c6f14548 25'to come to.' . "\n\n\n!\n\n";
8d063cd8 26
7bbfeec9 27is($x, $y, 'test data is sane');
8d063cd8 28
7bbfeec9 29print TRY $x;
d1e4d418 30close TRY or die "Could not close: $!";
8d063cd8 31
2d90ac95 32open(TRY,$filename) || (die "Can't reopen $filename: $!");
8d063cd8
LW
33$count = 0;
34$z = '';
7bbfeec9 35while (<TRY>) {
8d063cd8
LW
36 $z .= $_;
37 $count = $count + 1;
38}
39
7bbfeec9 40is($z, $y, 'basic multiline reading');
8d063cd8 41
7bbfeec9
MS
42is($count, 7, ' line count');
43is($., 7, ' $.' );
8d063cd8 44
3551ef6f
CB
45$out = (($^O eq 'MSWin32') || $^O eq 'NetWare') ? `type $filename`
46 : ($^O eq 'VMS') ? `type $filename.;0` # otherwise .LIS is assumed
2d90ac95
NC
47 : ($^O eq 'MacOS') ? `catenate $filename`
48 : `cat $filename`;
8d063cd8 49
7bbfeec9 50like($out, qr/.*\n.*\n.*\n$/);
bbad3607 51
2d90ac95 52close(TRY) || (die "Can't close $filename: $!");
8d063cd8 53
7bbfeec9 54is($out, $y);