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