From 75808db17caf8b960b351e3408e74142f4c85aac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:42:30 +0200 Subject: Adding upstream version 2.117.0. Signed-off-by: Daniel Baumann --- t/scripts/Lintian/Relation/05-invalid.t | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 t/scripts/Lintian/Relation/05-invalid.t (limited to 't/scripts/Lintian/Relation/05-invalid.t') diff --git a/t/scripts/Lintian/Relation/05-invalid.t b/t/scripts/Lintian/Relation/05-invalid.t new file mode 100755 index 0000000..9b42d62 --- /dev/null +++ b/t/scripts/Lintian/Relation/05-invalid.t @@ -0,0 +1,66 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +use Lintian::Relation; + +test_relation( + 'pkg%any (>= 1.0) , pkgB | _gf , pkgC(>=2.0)', + 'satisfied' => [ + 'pkgB | _gf', # partly unparsable, but identity holds + 'pkgC (>= 1.0)', # regular entry + ], + 'not-satisfied' => [ + 'pkg', # unparsable + 'pkg%any', # unparsable + 'pkgB', # OR relation with unparsable entry + '_gf', # OR relation + ], + 'unparsable' => ['_gf', 'pkg%any (>= 1.0)'], + 'reconstituted' => 'pkg%any (>= 1.0), pkgB | _gf, pkgC (>= 2.0)' +); + +done_testing; + +sub test_relation { + my ($text, %tests) = @_; + + my $relation_under_test = Lintian::Relation->new->load($text); + + my $tests = 0; + if (my $reconstituted = $tests{'reconstituted'}) { + is($relation_under_test->to_string, + $reconstituted, "Reconstitute $text"); + $tests++; + } + + for my $other_relation (@{$tests{'satisfied'} // [] }) { + ok($relation_under_test->satisfies($other_relation), + "'$text' satisfies '$other_relation'"); + $tests++; + } + + for my $other_relation (@{$tests{'not-satisfied'} // [] }) { + ok( + !$relation_under_test->satisfies($other_relation), + "'$text' does NOT satisfy '$other_relation'" + ); + $tests++; + } + + if (my $unparsable = $tests{'unparsable'}) { + my @actual = $relation_under_test->unparsable_predicates; + is_deeply(\@actual, $unparsable, "Unparsable entries for '$text'"); + } + + cmp_ok($tests, '>=', 1, "Ran at least one test on '$text'"); + return; +} + +# Local Variables: +# indent-tabs-mode: nil +# cperl-indent-level: 4 +# End: +# vim: syntax=perl sw=4 sts=4 sr et -- cgit v1.2.3