4 if ( $ENV{PERL_CORE} ) {
6 @INC = ( '../lib', '../ext/Test-Harness/t/lib' );
15 use Test::More tests => 26;
20 use TAP::Parser::Source;
21 use TAP::Parser::Source::Perl;
23 my $parser = EmptyParser->new;
24 my $test = File::Spec->catfile(
26 ? ( File::Spec->updir(), 'ext', 'Test-Harness' )
36 can_ok 'TAP::Parser::Source', 'new';
37 my $source = TAP::Parser::Source->new;
38 isa_ok $source, 'TAP::Parser::Source';
40 can_ok $source, 'source';
41 eval { $source->source("$perl -It/lib $test") };
42 ok my $error = $@, '... and calling it with a string should fail';
43 like $error, qr/^Argument to &source must be an array reference/,
44 '... with an appropriate error message';
45 ok $source->source( [ $perl, '-It/lib', '-T', $test ] ),
46 '... and calling it with valid args should succeed';
48 can_ok $source, 'get_stream';
49 my $stream = $source->get_stream($parser);
51 isa_ok $stream, 'TAP::Parser::Iterator::Process',
52 'get_stream returns the right object';
53 can_ok $stream, 'next';
54 is $stream->next, '1..1', '... and the first line should be correct';
55 is $stream->next, 'ok 1', '... as should the second';
56 ok !$stream->next, '... and we should have no more results';
58 can_ok 'TAP::Parser::Source::Perl', 'new';
59 $source = TAP::Parser::Source::Perl->new;
60 isa_ok $source, 'TAP::Parser::Source::Perl', '... and the object it returns';
62 can_ok $source, 'source';
63 ok $source->source( [$test] ),
64 '... and calling it with valid args should succeed';
66 can_ok $source, 'get_stream';
67 $stream = $source->get_stream($parser);
69 isa_ok $stream, 'TAP::Parser::Iterator::Process',
70 '... and the object it returns';
71 can_ok $stream, 'next';
72 is $stream->next, '1..1', '... and the first line should be correct';
73 is $stream->next, 'ok 1', '... as should the second';
74 ok !$stream->next, '... and we should have no more results';
78 can_ok $source, '_switches';
79 ok( grep( $_ =~ /^['"]?-T['"]?$/, $source->_switches ),
80 '... and it should find the taint switch'
83 # coverage test for TAP::PArser::Source
87 # coverage for method get_steam
89 my $source = TAP::Parser::Source->new( { parser => $parser } );
94 local $SIG{__DIE__} = sub { push @die, @_ };
99 is @die, 1, 'coverage testing of get_stream';
101 like pop @die, qr/No command found!/, '...and it failed as expect';