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