Add standard core test header to Test::Builder::Tester tests.
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / diag.t
CommitLineData
a9153838 1#!perl -w
2
3BEGIN {
4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
7483b81c 6 @INC = ('../lib', 'lib');
7 }
8 else {
9 unshift @INC, 't/lib';
a9153838 10 }
11}
12
30e302f8 13
14# Turn on threads here, if available, since this test tends to find
15# lots of threading bugs.
16use Config;
17BEGIN {
18 if( $] >= 5.008 && $Config{useithreads} ) {
19 require threads;
20 'threads'->import;
21 }
22}
23
24
a9153838 25use strict;
a9153838 26
7483b81c 27use Test::More tests => 5;
a9153838 28
29my $Test = Test::More->builder;
30
31# now make a filehandle where we can send data
7483b81c 32use TieOut;
33my $output = tie *FAKEOUT, 'TieOut';
a9153838 34
89c1e84a 35# force diagnostic output to a filehandle, glad I added this to
36# Test::Builder :)
89c1e84a 37my $ret;
a9153838 38{
39 local $TODO = 1;
40 $Test->todo_output(\*FAKEOUT);
41
42 diag("a single line");
43
89c1e84a 44 $ret = diag("multiple\n", "lines");
a9153838 45}
46
7483b81c 47is( $output->read, <<'DIAG', 'diag() with todo_output set' );
48# a single line
49# multiple
50# lines
51DIAG
52
89c1e84a 53ok( !$ret, 'diag returns false' );
a9153838 54
55{
89c1e84a 56 $Test->failure_output(\*FAKEOUT);
89c1e84a 57 $ret = diag("# foo");
a9153838 58}
89c1e84a 59$Test->failure_output(\*STDERR);
7483b81c 60is( $output->read, "# # foo\n", "diag() adds # even if there's one already" );
89c1e84a 61ok( !$ret, 'diag returns false' );
a9153838 62
a9153838 63
7483b81c 64# [rt.cpan.org 8392]
65{
66 $Test->failure_output(\*FAKEOUT);
67 diag(qw(one two));
a9153838 68}
7483b81c 69$Test->failure_output(\*STDERR);
70is( $output->read, <<'DIAG' );
71# onetwo
72DIAG