Dpkg

 view release on metacpan or  search on metacpan

t/Dpkg_Deps.t  view on Meta::CPAN

my $dep_virtual = deps_parse($field_virtual);
$dep_virtual->simplify_deps($facts);
is($dep_virtual->output(), '',
    'Simplify unversioned depends with unversioned virtual (satisfied)');

$field_virtual = 'myvirtual (>= 1.0) | other';
$dep_virtual = deps_parse($field_virtual);
$dep_virtual->simplify_deps($facts);
is($dep_virtual->output(), 'myvirtual (>= 1.0) | other',
    'Simplify versioned depends on unversioned virtual (unsatisfied)');

$field_virtual = 'myvirtual2 (>= 0.0) | other';
$dep_virtual = deps_parse($field_virtual);
$dep_virtual->simplify_deps($facts);
is($dep_virtual->output(), '',
    'Simplify versioned depends on versioned virtual (satisfied)');

$field_virtual = 'myvirtual2 (>= 2.0) | other';
$dep_virtual = deps_parse($field_virtual);
$dep_virtual->simplify_deps($facts);
is($dep_virtual->output(), 'myvirtual2 (>= 2.0) | other',
    'Simplify versioned depends on versioned virtual (unsatisfied)');

$field_virtual = 'myvirtual3 (= 2.0-1)';
$dep_virtual = deps_parse($field_virtual);
$dep_virtual->simplify_deps($facts);
is($dep_virtual->output(), 'myvirtual3 (= 2.0-1)',
    'Simplify versioned depends on GT versioned virtual (unsatisfied/ignored)');

my $field_dup_union = 'libc6 (>> 2.3), libc6 (>= 2.6-1), fake (<< 2.0),
fake(>> 3.0), fake (= 2.5), python (<< 2.5), python (= 2.4)';
my $dep_dup_union = deps_parse($field_dup_union,
    union => 1,
);
$dep_dup_union->simplify_deps($facts);
is($dep_dup_union->output(), 'libc6 (>> 2.3), fake (<< 2.0), fake (>> 3.0), fake (= 2.5), python (<< 2.5)', 'Simplify union deps');

$dep_dup_union = deps_parse('sipsak (<= 0.9.6-2.1), sipsak (<= 0.9.6-2.2)',
    union => 1,
);
$dep_dup_union->simplify_deps($facts);
is($dep_dup_union->output(), 'sipsak (<= 0.9.6-2.2)', 'Simplify union deps 2');

my $dep_red = deps_parse('abc | xyz, two, abc');
$dep_red->simplify_deps($facts, $dep_opposite);
is($dep_red->output(), 'abc, two', 'Simplification respect order');
is("$dep_red", $dep_red->output(), 'Stringification == output()');

my $dep_profiles = deps_parse('dupe <stage1 cross>, dupe <stage1 cross>');
$dep_profiles->simplify_deps($facts);
is($dep_profiles->output(), 'dupe <stage1 cross>',
    'Simplification respects duplicated profiles');

TODO: {

local $TODO = 'not yet implemented';

$dep_profiles = deps_parse('tool <!cross>, tool <stage1 cross>');
$dep_profiles->simplify_deps($facts);
is($dep_profiles->output(), 'tool <!cross> <stage1 cross>',
    'Simplify restriction formulas');

} # TODO.

$dep_profiles = deps_parse('libfoo-dev:native <!stage1>, libfoo-dev <!stage1 cross>',
    build_dep => 1,
);
$dep_profiles->simplify_deps($facts);
is($dep_profiles->output(),
    'libfoo-dev:native <!stage1>, libfoo-dev <!stage1 cross>',
    'Simplification respects archqualifiers and profiles');

my $dep_archqual = deps_parse('pkg, pkg:any');
$dep_archqual->simplify_deps($facts);
is($dep_archqual->output(), 'pkg, pkg:any',
    'Simplify respect arch-qualified ANDed dependencies 1/2');

$dep_archqual = deps_parse('pkg:amd64, pkg:any, pkg:i386');
$dep_archqual->simplify_deps($facts);
is($dep_archqual->output(), 'pkg:amd64, pkg:any, pkg:i386',
    'Simplify respects arch-qualified ANDed dependencies 2/2');

$dep_archqual = deps_parse('pkg | pkg:any');
$dep_archqual->simplify_deps($facts);
is($dep_archqual->output(), 'pkg | pkg:any',
    'Simplify respect arch-qualified ORed dependencies 1/2');

$dep_archqual = deps_parse('pkg:amd64 | pkg:i386 | pkg:any');
$dep_archqual->simplify_deps($facts);
is($dep_archqual->output(), 'pkg:amd64 | pkg:i386 | pkg:any',
    'Simplify respect arch-qualified ORed dependencies 2/2');

my $dep_version = deps_parse('pkg, pkg (= 1.0)');
$dep_version->simplify_deps($facts);
is($dep_version->output(), 'pkg (= 1.0)', 'Simplification merges versions');

my $dep_empty1 = deps_parse('');
is($dep_empty1->output(), '', 'Empty dependency');

my $dep_empty2 = deps_parse(' , , ',
    union => 1,
);
is($dep_empty2->output(), '', "' , , ' is also an empty dependency");

# Check sloppy but acceptable dependencies.

my $dep_sloppy_version = deps_parse('package (=   1.0  )');
is($dep_sloppy_version->output(), 'package (= 1.0)', 'sloppy version restriction');

my $dep_sloppy_arch = deps_parse('package [  alpha    ]');
is($dep_sloppy_arch->output(), 'package [alpha]', 'sloppy arch restriction');

my $dep_sloppy_profile = deps_parse('package <  !profile    >   <  other  >');
is($dep_sloppy_profile->output(), 'package <!profile> <other>',
    'sloppy profile restriction');

$SIG{__WARN__} = sub {};

my $dep_bad_version = deps_parse('package (= 1.0) (>= 2.0)');
is($dep_bad_version, undef, 'Bogus repeated version restriction');



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