6 use Test::More tests => 33;
10 my $tap = <<'END_TAP';
12 ok 1 - input file opened
14 not ok first line of the input valid # todo some data
16 ok 3 - read the rest of the file
17 not ok 4 - this is a real failure
18 Bail out! We ran out of foobar.
20 my $parser = TAP::Parser->new( { tap => $tap } );
21 isa_ok $parser, 'TAP::Parser',
22 '... we should be able to parse bailed out tests';
25 while ( my $result = $parser->next ) {
26 push @results => $result;
29 can_ok $parser, 'passed';
30 is $parser->passed, 3,
31 '... and we shold have the correct number of passed tests';
32 is_deeply [ $parser->passed ], [ 1, 2, 3 ],
33 '... and get a list of the passed tests';
35 can_ok $parser, 'failed';
36 is $parser->failed, 1, '... and the correct number of failed tests';
37 is_deeply [ $parser->failed ], [4], '... and get a list of the failed tests';
39 can_ok $parser, 'actual_passed';
40 is $parser->actual_passed, 2,
41 '... and we shold have the correct number of actually passed tests';
42 is_deeply [ $parser->actual_passed ], [ 1, 3 ],
43 '... and get a list of the actually passed tests';
45 can_ok $parser, 'actual_failed';
46 is $parser->actual_failed, 2,
47 '... and the correct number of actually failed tests';
48 is_deeply [ $parser->actual_failed ], [ 2, 4 ],
49 '... or get a list of the actually failed tests';
51 can_ok $parser, 'todo';
53 '... and we should have the correct number of TODO tests';
54 is_deeply [ $parser->todo ], [2], '... and get a list of the TODO tests';
57 '... and we should have the correct number of skipped tests';
61 can_ok $parser, 'plan';
62 is $parser->plan, '1..4', '... and we should have the correct plan';
63 is $parser->tests_planned, 4, '... and the correct number of tests';
67 ok @results, 'The parser should return results';
68 is scalar @results, 8, '... and there should be one for each line';
72 my $result = shift @results;
73 ok $result->is_plan, 'We should have a plan';
75 # a normal, passing test
77 my $test = shift @results;
78 ok $test->is_test, '... and a test';
80 # junk lines should be preserved
82 my $unknown = shift @results;
83 ok $unknown->is_unknown, '... and an unknown line';
85 # a failing test, which also happens to have a directive
87 my $failed = shift @results;
88 ok $failed->is_test, '... and another test';
92 my $comment = shift @results;
93 ok $comment->is_comment, '... and a comment';
95 # another normal, passing test
97 $test = shift @results;
98 ok $test->is_test, '... and another test';
102 $failed = shift @results;
103 ok $failed->is_test, '... and yet another test';
105 # ok 5 # skip we have no description
107 my $bailout = shift @results;
108 ok $bailout->is_bailout, 'And finally we should have a bailout';
109 is $bailout->as_string, 'We ran out of foobar.',
110 '... and as_string() should return the explanation';
111 is $bailout->raw, 'Bail out! We ran out of foobar.',
112 '... and raw() should return the explanation';
113 is $bailout->explanation, 'We ran out of foobar.',
114 '... and it should have the correct explanation';