File: 16_xml.t

package info (click to toggle)
libppi-perl 1.283-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,216 kB
  • sloc: perl: 15,295; makefile: 8
file content (47 lines) | stat: -rwxr-xr-x 1,017 bytes parent folder | download | duplicates (3)
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

use lib 't/lib';
use PPI::Test::pragmas;
use PPI::Document ();
use Test::More 0.86 tests => 16 + ($ENV{AUTHOR_TESTING} ? 1 : 0);






#####################################################################
# 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++;
}