Commit | Line | Data |
a9153838 |
1 | #!perl -w |
2 | |
3 | BEGIN { |
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. |
16 | use Config; |
17 | BEGIN { |
b7f9bbeb |
18 | if( $] >= 5.008001 && $Config{useithreads} ) { |
30e302f8 |
19 | require threads; |
20 | 'threads'->import; |
21 | } |
22 | } |
23 | |
24 | |
a9153838 |
25 | use strict; |
a9153838 |
26 | |
7483b81c |
27 | use Test::More tests => 5; |
a9153838 |
28 | |
29 | my $Test = Test::More->builder; |
30 | |
31 | # now make a filehandle where we can send data |
7483b81c |
32 | use TieOut; |
33 | my $output = tie *FAKEOUT, 'TieOut'; |
a9153838 |
34 | |
89c1e84a |
35 | # force diagnostic output to a filehandle, glad I added this to |
36 | # Test::Builder :) |
89c1e84a |
37 | my $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 |
47 | is( $output->read, <<'DIAG', 'diag() with todo_output set' ); |
48 | # a single line |
49 | # multiple |
50 | # lines |
51 | DIAG |
52 | |
89c1e84a |
53 | ok( !$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 |
60 | is( $output->read, "# # foo\n", "diag() adds # even if there's one already" ); |
89c1e84a |
61 | ok( !$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); |
70 | is( $output->read, <<'DIAG' ); |
71 | # onetwo |
72 | DIAG |