Commit | Line | Data |
60ffb308 |
1 | #!/usr/bin/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 | use Test::More; |
14 | use Test::Builder; |
15 | my $Test = Test::Builder->new; |
16 | |
0257f296 |
17 | $Test->plan( tests => 9 ); |
60ffb308 |
18 | $Test->level(0); |
19 | |
20 | my @Expected_Details; |
21 | |
22 | $Test->is_num( scalar $Test->summary(), 0, 'no tests yet, no summary' ); |
23 | push @Expected_Details, { 'ok' => 1, |
24 | actual_ok => 1, |
25 | name => 'no tests yet, no summary', |
26 | type => '', |
27 | reason => '' |
28 | }; |
29 | |
30 | # Inline TODO tests will confuse pre 1.20 Test::Harness, so we |
31 | # should just avoid the problem and not print it out. |
0257f296 |
32 | my $out_fh = $Test->output; |
33 | my $todo_fh = $Test->todo_output; |
60ffb308 |
34 | my $start_test = $Test->current_test + 1; |
35 | require TieOut; |
36 | tie *FH, 'TieOut'; |
37 | $Test->output(\*FH); |
0257f296 |
38 | $Test->todo_output(\*FH); |
60ffb308 |
39 | |
40 | SKIP: { |
41 | $Test->skip( 'just testing skip' ); |
42 | } |
43 | push @Expected_Details, { 'ok' => 1, |
44 | actual_ok => 1, |
45 | name => '', |
46 | type => 'skip', |
47 | reason => 'just testing skip', |
48 | }; |
49 | |
50 | TODO: { |
51 | local $TODO = 'i need a todo'; |
52 | $Test->ok( 0, 'a test to todo!' ); |
53 | |
54 | push @Expected_Details, { 'ok' => 1, |
55 | actual_ok => 0, |
56 | name => 'a test to todo!', |
57 | type => 'todo', |
58 | reason => 'i need a todo', |
59 | }; |
60 | |
61 | $Test->todo_skip( 'i need both' ); |
62 | } |
63 | push @Expected_Details, { 'ok' => 1, |
64 | actual_ok => 0, |
65 | name => '', |
66 | type => 'todo_skip', |
67 | reason => 'i need both' |
68 | }; |
69 | |
70 | for ($start_test..$Test->current_test) { print "ok $_\n" } |
71 | $Test->output($out_fh); |
0257f296 |
72 | $Test->todo_output($todo_fh); |
60ffb308 |
73 | |
74 | $Test->is_num( scalar $Test->summary(), 4, 'summary' ); |
75 | push @Expected_Details, { 'ok' => 1, |
76 | actual_ok => 1, |
77 | name => 'summary', |
78 | type => '', |
79 | reason => '', |
80 | }; |
81 | |
82 | $Test->current_test(6); |
83 | print "ok 6 - current_test incremented\n"; |
84 | push @Expected_Details, { 'ok' => 1, |
85 | actual_ok => undef, |
86 | name => undef, |
87 | type => 'unknown', |
88 | reason => 'incrementing test number', |
89 | }; |
90 | |
91 | my @details = $Test->details(); |
92 | $Test->is_num( scalar @details, 6, |
93 | 'details() should return a list of all test details'); |
94 | |
95 | $Test->level(1); |
96 | is_deeply( \@details, \@Expected_Details ); |
0257f296 |
97 | |
98 | |
99 | # This test has to come last because it thrashes the test details. |
100 | { |
101 | my $curr_test = $Test->current_test; |
102 | $Test->current_test(4); |
103 | my @details = $Test->details(); |
104 | |
105 | $Test->current_test($curr_test); |
106 | $Test->is_num( scalar @details, 4 ); |
107 | } |