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 | |
17 | $Test->plan( tests => 8 ); |
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. |
32 | my $out_fh = $Test->output; |
33 | my $start_test = $Test->current_test + 1; |
34 | require TieOut; |
35 | tie *FH, 'TieOut'; |
36 | $Test->output(\*FH); |
37 | |
38 | SKIP: { |
39 | $Test->skip( 'just testing skip' ); |
40 | } |
41 | push @Expected_Details, { 'ok' => 1, |
42 | actual_ok => 1, |
43 | name => '', |
44 | type => 'skip', |
45 | reason => 'just testing skip', |
46 | }; |
47 | |
48 | TODO: { |
49 | local $TODO = 'i need a todo'; |
50 | $Test->ok( 0, 'a test to todo!' ); |
51 | |
52 | push @Expected_Details, { 'ok' => 1, |
53 | actual_ok => 0, |
54 | name => 'a test to todo!', |
55 | type => 'todo', |
56 | reason => 'i need a todo', |
57 | }; |
58 | |
59 | $Test->todo_skip( 'i need both' ); |
60 | } |
61 | push @Expected_Details, { 'ok' => 1, |
62 | actual_ok => 0, |
63 | name => '', |
64 | type => 'todo_skip', |
65 | reason => 'i need both' |
66 | }; |
67 | |
68 | for ($start_test..$Test->current_test) { print "ok $_\n" } |
69 | $Test->output($out_fh); |
70 | |
71 | $Test->is_num( scalar $Test->summary(), 4, 'summary' ); |
72 | push @Expected_Details, { 'ok' => 1, |
73 | actual_ok => 1, |
74 | name => 'summary', |
75 | type => '', |
76 | reason => '', |
77 | }; |
78 | |
79 | $Test->current_test(6); |
80 | print "ok 6 - current_test incremented\n"; |
81 | push @Expected_Details, { 'ok' => 1, |
82 | actual_ok => undef, |
83 | name => undef, |
84 | type => 'unknown', |
85 | reason => 'incrementing test number', |
86 | }; |
87 | |
88 | my @details = $Test->details(); |
89 | $Test->is_num( scalar @details, 6, |
90 | 'details() should return a list of all test details'); |
91 | |
92 | $Test->level(1); |
93 | is_deeply( \@details, \@Expected_Details ); |