This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add tests for object ~~ regexp
[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 my $filename = tempfile();
12 open(TRY,'>',$filename) || (die "Can't open $filename: $!");
13
14 $x = 'now is the time
15 for all good men
16 to 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
27 is($x, $y,  'test data is sane');
28
29 print TRY $x;
30 close TRY or die "Could not close: $!";
31
32 open(TRY,$filename) || (die "Can't reopen $filename: $!");
33 $count = 0;
34 $z = '';
35 while (<TRY>) {
36     $z .= $_;
37     $count = $count + 1;
38 }
39
40 is($z, $y,  'basic multiline reading');
41
42 is($count, 7,   '    line count');
43 is($., 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
50 like($out, qr/.*\n.*\n.*\n$/);
51
52 close(TRY) || (die "Can't close $filename: $!");
53
54 is($out, $y);