6 if( $ENV{PERL_CORE} ) {
8 @INC = ('../lib', 'lib');
11 unshift @INC, 't/lib';
18 # The real Test::Builder
19 my $Test = Test::Builder->new;
20 $Test->plan( tests => 6 );
23 # The one we're going to test.
24 my $tb = Test::Builder->create();
26 my $tmpfile = 'foo.tmp';
27 END { 1 while unlink($tmpfile) }
29 # Test output to a file
31 my $out = $tb->output($tmpfile);
32 $Test->ok( defined $out );
38 open(IN, $tmpfile) or die $!;
39 chomp(my $line = <IN>);
42 $Test->is_eq($line, 'hi!');
46 # Test output to a filehandle
48 open(FOO, ">>$tmpfile") or die $!;
49 my $out = $tb->output(\*FOO);
50 my $old = select *$out;
55 open(IN, $tmpfile) or die $!;
59 $Test->like($lines[1], qr/Hello!/);
63 # Test output to a scalar ref
66 my $out = $tb->output(\$scalar);
68 print $out "Hey hey hey!\n";
69 $Test->is_eq($scalar, "Hey hey hey!\n");
73 # Test we can output to the same scalar ref
76 my $out = $tb->output(\$scalar);
77 my $err = $tb->failure_output(\$scalar);
79 print $out "To output ";
80 print $err "and beyond!";
82 $Test->is_eq($scalar, "To output and beyond!", "One scalar, two filehandles");
86 # Ensure stray newline in name escaping works.
89 my $out = $tb->output(\$fakeout);
90 $tb->exported_to(__PACKAGE__);
92 $tb->plan(tests => 5);
96 $tb->ok(1, "ok, like\nok");
97 $tb->skip("wibble\nmoof");
98 $tb->todo_skip("todo\nskip\n");
100 $Test->is_eq( $fakeout, <<OUTPUT ) || print STDERR $fakeout;
109 not ok 5 # TODO & SKIP todo