Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmp_document branch #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions t/05_lexer.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Compare a large number of specific constructs
# with the expected Lexer dumps.

use lib 't/lib';
use strict;
BEGIN {
no warnings 'once';
Expand All @@ -23,7 +24,7 @@ use PPI::Dumper;
use Test::More tests => 219;
use Test::NoWarnings;
use File::Spec::Functions ':ALL';
use t::lib::PPI;
use PPI::Test::Run;



Expand All @@ -33,4 +34,4 @@ use t::lib::PPI;
# Code/Dump Testing
# ntests = 2 + 15 * nfiles

t::lib::PPI->run_testdir( catdir( 't', 'data', '05_lexer' ) );
PPI::Test::Run->run_testdir( catdir( 't', 'data', '05_lexer' ) );
37 changes: 20 additions & 17 deletions t/07_token.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Formal unit tests for specific PPI::Token classes

use lib 't/lib';
use strict;
BEGIN {
no warnings 'once';
Expand All @@ -10,11 +11,11 @@ BEGIN {
$PPI::Lexer::X_TOKENIZER ||= $ENV{X_TOKENIZER};
}

# Execute the tests
use Test::More tests => 447;
use Test::NoWarnings;
use File::Spec::Functions ':ALL';
use t::lib::PPI;
use List::MoreUtils ();
use PPI::Test::Run;
use PPI;


Expand All @@ -25,7 +26,7 @@ use PPI;
# Code/Dump Testing
# ntests = 2 + 12 * nfiles

t::lib::PPI->run_testdir( catdir( 't', 'data', '07_token' ) );
PPI::Test::Run->run_testdir( catdir( 't', 'data', '07_token' ) );



Expand All @@ -49,7 +50,7 @@ SCOPE: {
'@::foo' => '@main::foo',
'$foo::bar' => '$foo::bar',
'$ foo\'bar' => '$foo::bar',
);
);
while ( @symbols ) {
my ($value, $canon) = ( shift(@symbols), shift(@symbols) );
my $Symbol = PPI::Token::Symbol->new( $value );
Expand Down Expand Up @@ -155,10 +156,11 @@ foreach my $code ( '08', '09', '0778', '0779' ) {
isa_ok($token, 'PPI::Token::Number::Octal');
is("$token", $code, "tokenize bad octal '$code'");
ok($token->{_error} && $token->{_error} =~ m/octal/i,
'invalid octal number should trigger parse error');
'invalid octal number should trigger parse error');
is($token->literal, undef, "literal('$code') is undef");
}


BINARY: {
my @tests = (
# Good binary numbers
Expand All @@ -175,25 +177,26 @@ BINARY: {
{ code => '0b012', error => 1, value => 0 },
{ code => '0B012', error => 1, value => 0 },
{ code => '0B0121', error => 1, value => 0 },
);
);
foreach my $test ( @tests ) {
my $code = $test->{code};
my $T = PPI::Tokenizer->new( \$code );
my $token = $T->get_token;
isa_ok($token, 'PPI::Token::Number::Binary');
if ( $test->{error} ) {
ok($token->{_error} && $token->{_error} =~ m/binary/i,
'invalid binary number should trigger parse error');
is($token->literal, undef, "literal('$code') is undef");
}
else {
ok(!$token->{_error}, "no error for '$code'");
is($token->literal, $test->{value}, "literal('$code') is $test->{value}");
}
is($token->content, $code, "parsed everything");
if ( $test->{error} ) {
ok($token->{_error} && $token->{_error} =~ m/binary/i,
'invalid binary number should trigger parse error');
is($token->literal, undef, "literal('$code') is undef");
}
else {
ok(!$token->{_error}, "no error for '$code'");
is($token->literal, $test->{value}, "literal('$code') is $test->{value}");
}
is($token->content, $code, "parsed everything");
}
}


HEX: {
my @tests = (
# Good hex numbers--entire thing goes in the token
Expand Down Expand Up @@ -233,6 +236,6 @@ HEX: {
isa_ok($token, 'PPI::Token::Number::Hex');
ok(!$token->{_error}, "no error for '$code' even on invalid digits");
is($token->content, $test->{parsed}, "correctly parsed everything expected");
is($token->literal, $test->{value}, "literal('$code') is $test->{value}");
is($token->literal, $test->{value}, "literal('$code') is $test->{value}");
}
}
5 changes: 3 additions & 2 deletions t/08_regression.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Some other regressions tests are included here for simplicity.

use lib 't/lib';
use strict;
BEGIN {
no warnings 'once';
Expand All @@ -17,7 +18,7 @@ use Test::More tests => 933;
use Test::NoWarnings;
use File::Spec::Functions ':ALL';
use Params::Util qw{_INSTANCE};
use t::lib::PPI;
use PPI::Test::Run;
use PPI::Lexer;
use PPI::Dumper;

Expand All @@ -35,7 +36,7 @@ sub pause {
# Code/Dump Testing
# ntests = 2 + 14 * nfiles

t::lib::PPI->run_testdir(qw{ t data 08_regression });
PPI::Test::Run->run_testdir(qw{ t data 08_regression });



Expand Down
3 changes: 2 additions & 1 deletion t/19_selftesting.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Using PPI to analyse its own code at install-time? Fuck yeah! :)

use lib 't/lib';
use strict;
BEGIN {
no warnings 'once';
Expand All @@ -20,7 +21,7 @@ use File::Spec::Functions ':ALL';
use Params::Util qw{_CLASS _ARRAY _INSTANCE _IDENTIFIER};
use Class::Inspector;
use PPI;
use t::lib::PPI;
use PPI::Test::Object;

use constant CI => 'Class::Inspector';

Expand Down
5 changes: 3 additions & 2 deletions t/25_increment.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# state between an empty document and the entire file to make sure
# all of them parse as legal documents and don't crash the parser.

use lib 't/lib';
use strict;
BEGIN {
no warnings 'once';
Expand All @@ -19,7 +20,7 @@ use File::Spec::Functions ':ALL';
use Params::Util qw{_INSTANCE};
use PPI::Lexer;
use PPI::Dumper;
use t::lib::PPI;
use PPI::Test::Run;



Expand All @@ -28,4 +29,4 @@ use t::lib::PPI;
#####################################################################
# Code/Dump Testing

t::lib::PPI->increment_testdir(qw{ t data 08_regression });
PPI::Test::Run->increment_testdir(qw{ t data 08_regression });
5 changes: 3 additions & 2 deletions t/26_bom.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/perl

use lib 't/lib';
use strict;
BEGIN {
no warnings 'once';
Expand All @@ -11,7 +12,7 @@ BEGIN {
# For each new item in t/data/08_regression add another 14 tests
use Test::More tests => 21;
use Test::NoWarnings;
use t::lib::PPI;
use PPI::Test::Run;
use PPI;


Expand All @@ -22,4 +23,4 @@ use PPI;
# Code/Dump Testing
# ntests = 2 + 14 * nfiles

t::lib::PPI->run_testdir(qw{ t data 26_bom });
PPI::Test::Run->run_testdir(qw{ t data 26_bom });
Loading