File: ppi_token_magic.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 (56 lines) | stat: -rw-r--r-- 1,303 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
#!/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 => 30;

# =begin testing __TOKENIZER_on_char 30
{
my $document = PPI::Document->new(\<<'END_PERL');
$[;			# Magic  $[
$$;			# Magic  $$
%-;			# Magic  %-
$#-;			# Magic  $#-
$$foo;			# Symbol $foo		Dereference of $foo
$^W;			# Magic  $^W
$^WIDE_SYSTEM_CALLS;	# Magic  $^WIDE_SYSTEM_CALLS
${^MATCH};		# Magic  ${^MATCH}
@{^_Bar};		# Magic  @{^_Bar}
${^_Bar}[0];		# Magic  @{^_Bar}
%{^_Baz};		# Magic  %{^_Baz}
${^_Baz}{burfle};	# Magic  %{^_Baz}
$${^MATCH};		# Magic  ${^MATCH}	Dereference of ${^MATCH}
\${^MATCH};		# Magic  ${^MATCH}
END_PERL

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

$document->index_locations();

my $symbols = $document->find( 'PPI::Token::Symbol' );

is( scalar(@$symbols), 14, 'Found 14 symbols' );
my $comments = $document->find( 'PPI::Token::Comment' );

foreach my $token ( @$symbols ) {
	my ($hash, $class, $name, $remk) =
		split '\s+', $comments->[$token->line_number - 1], 4;
	isa_ok( $token, "PPI::Token::$class" );
	is( $token->symbol, $name, $remk || "The symbol is $name" );
}
}


1;