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