Skip to content

Commit 97943c3

Browse files
committed
add some more coverage for untested subs
1 parent a342f72 commit 97943c3

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

t/15_transform.t

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl
22

33
use t::lib::PPI::Test::pragmas;
4-
use Test::More 0.86 tests => 23 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
4+
use Test::More 0.86 tests => 24 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
55

66
use File::Spec::Functions ':ALL';
77
use File::Remove;
@@ -101,6 +101,11 @@ foreach my $input ( @files ) {
101101
}
102102

103103

104+
eval { PPI::Transform->document };
105+
like $@, qr/PPI::Transform does not implement the required ->document method/,
106+
"transform classes need to implement ->document";
107+
108+
104109

105110

106111

t/ppi_lexer.t

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Unit testing for PPI::Lexer
44

55
use t::lib::PPI::Test::pragmas;
6-
use Test::More tests => 43 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
6+
use Test::More tests => 46 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
77

88
use PPI;
99

@@ -147,3 +147,10 @@ LEX_STRUCTURE: {
147147
# Validate the creation of an empty statement
148148
new_ok( 'PPI::Statement' => [ ] );
149149
}
150+
151+
ERROR_HANDLING: {
152+
my $test_lexer = PPI::Lexer->new;
153+
is $test_lexer->errstr, "", "errstr is an empty string at the start";
154+
is $test_lexer->lex_file( undef ), undef, "lex_file fails without a filename";
155+
is( PPI::Lexer->errstr, "Did not pass a filename to PPI::Lexer::lex_file", "error can be gotten from class attribute" );
156+
}

t/ppi_token.t

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/perl
2+
3+
# Unit testing for PPI::Token
4+
5+
use t::lib::PPI::Test::pragmas;
6+
use Test::More tests => 5 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
7+
8+
use PPI;
9+
10+
MODIFICATION: {
11+
my $one = PPI::Token->new( "" );
12+
is $one->length, 0, "empty token has no length";
13+
ok $one->add_content( "abcde" ), "can add strings";
14+
is $one->length, 5, "adding actually adds";
15+
ok $one->set_content( "abc" ), "can set content";
16+
is $one->length, 3, "setting overwrites";
17+
}

t/ppi_token_whitespace.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/perl
2+
3+
# Unit testing for PPI::Token::Whitespace
4+
5+
use t::lib::PPI::Test::pragmas;
6+
use Test::More tests => 6 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 );
7+
8+
use PPI;
9+
10+
TIDY: {
11+
my $ws1 = PPI::Token::Whitespace->new( " " );
12+
is $ws1->length, "3";
13+
ok $ws1->tidy;
14+
is $ws1->length, "3";
15+
my $ws2 = PPI::Token::Whitespace->new( " \n" );
16+
is $ws2->length, "4";
17+
ok $ws2->tidy;
18+
is $ws2->length, "0";
19+
}

0 commit comments

Comments
 (0)