Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
853410bb |
3 | BEGIN { |
7bbfeec9 |
4 | chdir 't'; |
5 | @INC = '../lib'; |
6 | require './test.pl'; |
7 | } |
8d063cd8 |
8 | |
7bbfeec9 |
9 | plan(tests => 6); |
8d063cd8 |
10 | |
2d90ac95 |
11 | my $filename = tempfile(); |
12 | open(TRY,'>',$filename) || (die "Can't open $filename: $!"); |
8d063cd8 |
13 | |
14 | $x = 'now is the time |
15 | for all good men |
16 | to come to. |
c6f14548 |
17 | |
18 | |
19 | ! |
20 | |
8d063cd8 |
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 |
27 | is($x, $y, 'test data is sane'); |
8d063cd8 |
28 | |
7bbfeec9 |
29 | print TRY $x; |
d1e4d418 |
30 | close TRY or die "Could not close: $!"; |
8d063cd8 |
31 | |
2d90ac95 |
32 | open(TRY,$filename) || (die "Can't reopen $filename: $!"); |
8d063cd8 |
33 | $count = 0; |
34 | $z = ''; |
7bbfeec9 |
35 | while (<TRY>) { |
8d063cd8 |
36 | $z .= $_; |
37 | $count = $count + 1; |
38 | } |
39 | |
7bbfeec9 |
40 | is($z, $y, 'basic multiline reading'); |
8d063cd8 |
41 | |
7bbfeec9 |
42 | is($count, 7, ' line count'); |
43 | is($., 7, ' $.' ); |
8d063cd8 |
44 | |
06d90eb2 |
45 | $out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type $filename` |
2d90ac95 |
46 | : ($^O eq 'MacOS') ? `catenate $filename` |
47 | : `cat $filename`; |
8d063cd8 |
48 | |
7bbfeec9 |
49 | like($out, qr/.*\n.*\n.*\n$/); |
bbad3607 |
50 | |
2d90ac95 |
51 | close(TRY) || (die "Can't close $filename: $!"); |
8d063cd8 |
52 | |
7bbfeec9 |
53 | is($out, $y); |