9 use Test::More tests => 26;
14 use TAP::Parser::Source;
15 use TAP::Parser::Source::Perl;
17 my $parser = EmptyParser->new;
18 my $test = File::Spec->catfile(
26 can_ok 'TAP::Parser::Source', 'new';
27 my $source = TAP::Parser::Source->new;
28 isa_ok $source, 'TAP::Parser::Source';
30 can_ok $source, 'source';
31 eval { $source->source("$perl -It/lib $test") };
32 ok my $error = $@, '... and calling it with a string should fail';
33 like $error, qr/^Argument to &source must be an array reference/,
34 '... with an appropriate error message';
35 ok $source->source( [ $perl, '-It/lib', '-T', $test ] ),
36 '... and calling it with valid args should succeed';
38 can_ok $source, 'get_stream';
39 my $stream = $source->get_stream($parser);
41 isa_ok $stream, 'TAP::Parser::Iterator::Process',
42 'get_stream returns the right object';
43 can_ok $stream, 'next';
44 is $stream->next, '1..1', '... and the first line should be correct';
45 is $stream->next, 'ok 1', '... as should the second';
46 ok !$stream->next, '... and we should have no more results';
48 can_ok 'TAP::Parser::Source::Perl', 'new';
49 $source = TAP::Parser::Source::Perl->new;
50 isa_ok $source, 'TAP::Parser::Source::Perl', '... and the object it returns';
52 can_ok $source, 'source';
53 ok $source->source( [$test] ),
54 '... and calling it with valid args should succeed';
56 can_ok $source, 'get_stream';
57 $stream = $source->get_stream($parser);
59 isa_ok $stream, 'TAP::Parser::Iterator::Process',
60 '... and the object it returns';
61 can_ok $stream, 'next';
62 is $stream->next, '1..1', '... and the first line should be correct';
63 is $stream->next, 'ok 1', '... as should the second';
64 ok !$stream->next, '... and we should have no more results';
68 can_ok $source, '_switches';
69 ok( grep( $_ =~ /^['"]?-T['"]?$/, $source->_switches ),
70 '... and it should find the taint switch'
73 # coverage test for TAP::PArser::Source
77 # coverage for method get_steam
79 my $source = TAP::Parser::Source->new( { parser => $parser } );
84 local $SIG{__DIE__} = sub { push @die, @_ };
89 is @die, 1, 'coverage testing of get_stream';
91 like pop @die, qr/No command found!/, '...and it failed as expect';