File: ppi_statement.t

package info (click to toggle)
libppi-perl 1.215-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,820 kB
  • sloc: perl: 12,129; makefile: 8
file content (60 lines) | stat: -rw-r--r-- 2,576 bytes parent folder | download | duplicates (2)
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
55
56
57
58
59
60
#!/usr/bin/perl

# Unit testing for PPI, generated by Test::Inline

use strict;
use File::Spec::Functions ':ALL';
BEGIN {
	$|  = 1;
	$^W = 1;
	no warnings 'once';
	$PPI::XS_DISABLE = 1;
	$PPI::Lexer::X_TOKENIZER ||= $ENV{X_TOKENIZER};
}
use PPI;

# Execute the tests
use Test::More tests => 22;

# =begin testing specialized 22
{
my $Document = PPI::Document->new(\<<'END_PERL');
package Foo;
use strict;
;
while (1) { last; }
BEGIN { }
sub foo { }
state $x;
$x = 5;
END_PERL

isa_ok( $Document, 'PPI::Document' );

my $statements = $Document->find('Statement');
is( scalar @{$statements}, 10, 'Found the 10 test statements' );

isa_ok( $statements->[0], 'PPI::Statement::Package',    'Statement 1: isa Package'            );
ok( $statements->[0]->specialized,                      'Statement 1: is specialized'         );
isa_ok( $statements->[1], 'PPI::Statement::Include',    'Statement 2: isa Include'            );
ok( $statements->[1]->specialized,                      'Statement 2: is specialized'         );
isa_ok( $statements->[2], 'PPI::Statement::Null',       'Statement 3: isa Null'               );
ok( $statements->[2]->specialized,                      'Statement 3: is specialized'         );
isa_ok( $statements->[3], 'PPI::Statement::Compound',   'Statement 4: isa Compound'           );
ok( $statements->[3]->specialized,                      'Statement 4: is specialized'         );
isa_ok( $statements->[4], 'PPI::Statement::Expression', 'Statement 5: isa Expression'         );
ok( $statements->[4]->specialized,                      'Statement 5: is specialized'         );
isa_ok( $statements->[5], 'PPI::Statement::Break',      'Statement 6: isa Break'              );
ok( $statements->[5]->specialized,                      'Statement 6: is specialized'         );
isa_ok( $statements->[6], 'PPI::Statement::Scheduled',  'Statement 7: isa Scheduled'          );
ok( $statements->[6]->specialized,                      'Statement 7: is specialized'         );
isa_ok( $statements->[7], 'PPI::Statement::Sub',        'Statement 8: isa Sub'                );
ok( $statements->[7]->specialized,                      'Statement 8: is specialized'         );
isa_ok( $statements->[8], 'PPI::Statement::Variable',   'Statement 9: isa Variable'           );
ok( $statements->[8]->specialized,                      'Statement 9: is specialized'         );
is( ref $statements->[9], 'PPI::Statement',             'Statement 10: is a simple Statement' );
ok( ! $statements->[9]->specialized,                    'Statement 10: is not specialized'    );
}


1;