6 use Test::More tests => 10;
9 use TAP::Parser::Iterator;
11 my $tap = <<'END_TAP';
13 ok 1 - input file opened
15 not ok first line of the input valid # todo some data
17 ok 3 - read the rest of the file
18 not ok 4 - this is a real failure
19 ok 5 # skip we have no description
30 $todo++ if $test->has_todo;
31 $skip++ if $test->has_skip;
35 $plan_output = $plan->as_string;
39 my $stream = TAP::Parser::Iterator->new( [ split /\n/ => $tap ] );
40 my $parser = TAP::Parser->new(
42 callbacks => \%callbacks,
46 can_ok $parser, 'run';
48 is $plan_output, '1..5', 'Plan callbacks should succeed';
49 is scalar @tests, $parser->tests_run, '... as should the test callbacks';
62 $todo++ if $test->has_todo;
63 $skip++ if $test->has_skip;
67 $plan_output = $plan->as_string;
70 $end = 1 if $all == 8;
80 $stream = TAP::Parser::Iterator->new( [ split /\n/ => $tap ] );
81 $parser = TAP::Parser->new(
83 callbacks => \%callbacks,
87 can_ok $parser, 'run';
89 is $plan_output, '1..5', 'Plan callbacks should succeed';
90 is scalar @tests, $parser->tests_run, '... as should the test callbacks';
91 is $else, 2, '... and the correct number of "ELSE" lines should be seen';
92 is $all, 8, '... and the correct total number of lines should be seen';
93 is $end, 1, 'EOF callback correctly called';
95 # Check callback name policing
105 $stream = TAP::Parser::Iterator->new( [ split /\n/ => $tap ] );
107 $parser = TAP::Parser->new(
109 callbacks => \%callbacks,
114 like $@, qr/Callback/, 'Bad callback keys faulted';