1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#!/usr/bin/perl
use strict;
BEGIN {
no warnings 'once';
$| = 1;
$PPI::XS_DISABLE = 1;
$PPI::Lexer::X_TOKENIZER ||= $ENV{X_TOKENIZER};
}
use Test::More 0.86 tests => 17;
use Test::NoWarnings;
use File::Spec::Functions ':ALL';
use PPI;
#####################################################################
# Begin Tests
my $code = 'print "Hello World";';
my $document = new_ok( 'PPI::Document' => [ \$code ] );
my @elements = $document->elements;
push @elements, $elements[0]->elements;
my @expected = (
[ 'statement', {}, '' ],
[ 'token_word', {}, 'print' ],
[ 'token_whitespace', {}, ' ' ],
[ 'token_quote_double', {}, '"Hello World"' ],
[ 'token_structure', {}, ';' ],
);
my $i = 0;
foreach my $expect ( @expected ) {
is(
$elements[$i]->_xml_name,
$expect->[0],
"Got _xml_name '$expect->[0]' as expected",
);
is_deeply(
$elements[$i]->_xml_attr,
$expect->[1],
"Got _xml_attr as expected",
);
is(
$elements[$i]->_xml_content,
$expect->[2],
"Got _xml_content '$expect->[2]' as expected",
);
$i++;
}
|