xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/comp/multiline.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN: {
4*0Sstevel@tonic-gate    chdir 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate    require './test.pl';
7*0Sstevel@tonic-gate}
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gateplan(tests => 6);
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gateopen(TRY,'>Comp.try') || (die "Can't open temp file.");
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate$x = 'now is the time
14*0Sstevel@tonic-gatefor all good men
15*0Sstevel@tonic-gateto come to.
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate!
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gate';
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate$y = 'now is the time' . "\n" .
23*0Sstevel@tonic-gate'for all good men' . "\n" .
24*0Sstevel@tonic-gate'to come to.' . "\n\n\n!\n\n";
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gateis($x, $y,  'test data is sane');
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateprint TRY $x;
29*0Sstevel@tonic-gateclose TRY or die "Could not close: $!";
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateopen(TRY,'Comp.try') || (die "Can't reopen temp file.");
32*0Sstevel@tonic-gate$count = 0;
33*0Sstevel@tonic-gate$z = '';
34*0Sstevel@tonic-gatewhile (<TRY>) {
35*0Sstevel@tonic-gate    $z .= $_;
36*0Sstevel@tonic-gate    $count = $count + 1;
37*0Sstevel@tonic-gate}
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gateis($z, $y,  'basic multiline reading');
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gateis($count, 7,   '    line count');
42*0Sstevel@tonic-gateis($., 7,       '    $.' );
43*0Sstevel@tonic-gate
44*0Sstevel@tonic-gate$out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type Comp.try`
45*0Sstevel@tonic-gate    : ($^O eq 'MacOS') ? `catenate Comp.try`
46*0Sstevel@tonic-gate    : `cat Comp.try`;
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gatelike($out, qr/.*\n.*\n.*\n$/);
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gateclose(TRY) || (die "Can't close temp file.");
51*0Sstevel@tonic-gateunlink 'Comp.try' || `/bin/rm -f Comp.try`;
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gateis($out, $y);
54