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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#
#===============================================================================
#
# FILE: 34strict.t
#
# DESCRIPTION:
#
# FILES: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: (), <>
# COMPANY:
# VERSION: 1.0
# CREATED: 2009-11-28 17.38.03 CET
# REVISION: ---
#===============================================================================
use strict;
use warnings;
use Test::More tests => 12; # last test to print
use Test::Exception;
BEGIN {
chdir 't' if -d 't';
use lib '../blib/lib', 'lib/', '..';
}
my $mod = "Parse::DebControl";
my $pdc;
my $data;
#Object initialization - 2 tests
use_ok($mod);
ok($pdc = new Parse::DebControl(), "Parser object creation works fine");
$pdc = new Parse::DebControl(1);
# Parse debian/control
lives_ok (sub {
$data = $pdc->parse_file( "testfiles/strict3.source", { strict => 1, type => 'debian/control', singeBlock => 1 } );
}, "parse debian/control");
# Parse DEBIAN/control
lives_ok (sub {
$data = $pdc->parse_file( "testfiles/strict4.binary", { strict => 1, type => 'DEBIAN/control', singeBlock => 1 } );
}, "parse DEBIAN/control");
# Parse .changes
lives_ok (sub {
$data = $pdc->parse_file( "testfiles/strict1.changes", { strict => 1, type => '.changes', singeBlock => 1 } );
}, "parse .changes");
# Parse .dsc
lives_ok (sub {
$data = $pdc->parse_file( "testfiles/strict2.dsc", { strict => 1, type => '.dsc', singeBlock => 1 } );
}, "parse .dsc");
ok($data = $pdc->parse_mem("Source: foo\n#This is a comment\nPackage: bar\#another comment\n#thid comment\nPriority: required", {strict => 1, type => 'debian/control'}), "Comments parse out correctly");
throws_ok {
$pdc->parse_mem(
"Source: foo\n#This is a comment\nPackage: bar\#another comment\n#thid comment\nPriority: required",
{strict => 1, type => 'DEBIAN/control'}
)
} 'Parse::DebControl::Error::Parse', "Error thrown";
throws_ok {
$pdc->parse_mem(
"Source: foo\nPackage: bar\nExtra: candy for me",
{strict => 1, type => 'debian/control'}
)
} 'Parse::DebControl::Error::Parse', "Error thrown for the extra field";
lives_ok {
$pdc->parse_mem(
"Format: 1.8\nSource: bar\n\nExtra: candy for me",
{strict => 1, type => '.dsc', singleBlock => 1}
)
} "Error not thrown when ignoring junk";
throws_ok {
$pdc->parse_mem(
"Source: foo\nPackage: bar\n\nExtra: candy for me",
{strict => 1, type => 'debian/control'}
)
} 'Parse::DebControl::Error::Parse', "Error thrown for the extra block";
lives_ok {
$pdc->parse_mem(
"Format: 1.8\nSource: bar\nX-Extra: candy for me",
{strict => 1, type => '.dsc'}
)
} "Error not thrown when local fields is used";
|