File: ppi_token_number_version.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 (36 lines) | stat: -rw-r--r-- 962 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
#!/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 => 9;

# =begin testing 9
{
my $doc1 = new_ok( 'PPI::Document' => [ \'1.2.3.4'  ] );
my $doc2 = new_ok( 'PPI::Document' => [ \'v1.2.3.4' ] );
isa_ok( $doc1->child(0), 'PPI::Statement' );
isa_ok( $doc2->child(0), 'PPI::Statement' );
isa_ok( $doc1->child(0)->child(0), 'PPI::Token::Number::Version' );
isa_ok( $doc2->child(0)->child(0), 'PPI::Token::Number::Version' );

my $literal1 = $doc1->child(0)->child(0)->literal;
my $literal2 = $doc2->child(0)->child(0)->literal;
is( length($literal1), 4, 'The literal length of doc1 is 4' );
is( length($literal2), 4, 'The literal length of doc1 is 4' );
is( $literal1, $literal2, 'Literals match for 1.2.3.4 vs v1.2.3.4' );
}


1;