two fake test failures on VMS fixed
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / output.t
1 #!perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6 }
7
8 # Can't use Test.pm, that's a 5.005 thing.
9 print "1..3\n";
10
11 my $test_num = 1;
12 # Utility testing functions.
13 sub ok ($;$) {
14     my($test, $name) = @_;
15     my $ok = '';
16     $ok .= "not " unless $test;
17     $ok .= "ok $test_num";
18     $ok .= " - $name" if defined $name;
19     $ok .= "\n";
20     print $ok;
21     $test_num++;
22 }
23
24 use Test::Builder;
25 my $Test = Test::Builder->new();
26
27 my $result;
28 my $out = $Test->output('foo');
29
30 ok( defined $out );
31
32 print $out "hi!\n";
33 close *$out;
34
35 undef $out;
36 open(IN, 'foo') or die $!;
37 chomp(my $line = <IN>);
38 close IN;
39 ok($line eq 'hi!');
40
41 open(FOO, ">>foo") or die $!;
42 $out = $Test->output(\*FOO);
43 $old = select *$out;
44 print "Hello!\n";
45 close *$out;
46 undef $out;
47 select $old;
48 open(IN, 'foo') or die $!;
49 my @lines = <IN>;
50 close IN;
51
52 ok($lines[1] =~ /Hello!/);
53
54 unlink('foo');