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
|
#!/usr/bin/perl
# Standalone tests to check "foreach qw{foo} {}"
use lib 't/lib';
use PPI::Test::pragmas;
use Test::More tests => 15 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
#use File::Spec::Functions ':ALL';
use PPI ();
use Helper 'safe_new';
#####################################################################
# Parse the canonical cases
SCOPE: {
my $string = 'for qw{foo} {} foreach';
my $document = safe_new \$string;
my $statements = $document->find('Statement::Compound');
is( scalar(@$statements), 2, 'Found 2 statements' );
is( $statements->[0]->type, 'foreach', '->type ok' );
is( $statements->[1]->type, 'foreach', '->type ok' );
}
SCOPE: {
my $string = 'foreach qw{foo} {} foreach';
my $document = safe_new \$string;
my $statements = $document->find('Statement::Compound');
is( scalar(@$statements), 2, 'Found 2 statements' );
is( $statements->[0]->type, 'foreach', '->type ok' );
is( $statements->[1]->type, 'foreach', '->type ok' );
}
SCOPE: {
my $string = 'for my $foo qw{bar} {} foreach';
my $document = safe_new \$string;
my $statements = $document->find('Statement::Compound');
is( scalar(@$statements), 2, 'Found 2 statements' );
is( $statements->[0]->type, 'foreach', '->type ok' );
is( $statements->[1]->type, 'foreach', '->type ok' );
}
1;
|