Parse-Deb-Control

 view release on metacpan or  search on metacpan

t/01_Parse-Deb-Control.t  view on Meta::CPAN

#!/usr/bin/perl

use strict;
use warnings;

#use Test::More 'no_plan';
use Test::More tests => 18;
use Test::Differences;
use Test::Exception;

use File::Spec;
use File::Slurp 'read_file';

use FindBin qw($Bin);
use lib "$Bin/lib";

BEGIN {
    use_ok ( 'Parse::Deb::Control' ) or exit;
}

exit main();

sub main {
	my $parser = Parse::Deb::Control->new(File::Spec->catfile($Bin, 'control', 'control-perl'));
	isa_ok($parser, 'Parse::Deb::Control');

	# check the generated control file content
	is(
		$parser->control,
		scalar read_file(File::Spec->catfile($Bin, 'control', 'control-perl')),
		'check the generated control file content',
	);
	
	my $content = $parser->content;
	is(
		scalar (grep { ($_ eq 'Package') or ($_ eq 'Source') } @{$parser->structure}),
		10,
		'10 paragraphs in this control file structure',
	);
	is(
		scalar @{$content},
		10,
		'10 paragraphs in this control file',
	);
	is(
		scalar ($parser->get_keys(qw{ Source Package })),
		10,
		'10 paragraphs in this control file',
	);

	my $parser2 = Parse::Deb::Control->new(File::Spec->catfile($Bin, 'control', 'control-perl-simple'));

	# check the generated control file content
	is(
		$parser2->control,
		scalar read_file(File::Spec->catfile($Bin, 'control', 'control-perl-simple')),
		'check the generated control file content',
	);

	my $content2 = $parser2->content;
	is(
		scalar (grep { ($_ eq 'Package') or ($_ eq 'Source') } @{$parser2->structure}),
		2,
		'2 paragraphs in this simple control file structure',
	);
	is(
		scalar @{$content2},
		2,



( run in 1.196 second using v1.01-cache-2.11-cpan-39bf76dae61 )