5 use Test
::Simple tests
=> 4 + 3*5*5 + 3;
7 use Fedora
::Rebuild
::RPM
;
9 # The ok() labels have format "REQUIRES ? COMMA_SEPARATED_PROVIDES".
11 # Non-flag-qualified cases
13 Fedora
::Rebuild
::RPM
::is_satisfied
(
14 'a', Fedora
::Rebuild
::RPM
::ANY
, '',
16 'a' => [ [Fedora
::Rebuild
::RPM
::ANY
, ''] ]
22 ! Fedora
::Rebuild
::RPM
::is_satisfied
(
23 'a', Fedora
::Rebuild
::RPM
::ANY
, '',
25 'b' => [ [Fedora
::Rebuild
::RPM
::ANY
, ''] ]
31 Fedora
::Rebuild
::RPM
::is_satisfied
(
32 'a', Fedora
::Rebuild
::RPM
::ANY
, '',
34 'b' => [ [Fedora
::Rebuild
::RPM
::ANY
, ''] ],
35 'a' => [ [Fedora
::Rebuild
::RPM
::ANY
, ''] ],
36 'c' => [ [Fedora
::Rebuild
::RPM
::ANY
, ''] ]
42 ! Fedora
::Rebuild
::RPM
::is_satisfied
(
43 'a', Fedora
::Rebuild
::RPM
::ANY
, '',
50 # A matrix case. See module comments for the matrices. There should be 3*5*5
52 sub test_matrix_cell
{
53 my ($order, $rflag, $pflag, $result) = @_;
55 my ($rversion, $pversion) = ('1', '1');
58 } elsif ($order > 0) {
63 $result == Fedora
::Rebuild
::RPM
::is_satisfied
(
64 'a', $rflag, $rversion,
66 'a' => [ [$pflag, $pversion] ]
69 'a ' . Fedora
::Rebuild
::RPM
::flag_as_string
($rflag) . " $rversion" .
70 ' ? a ' . Fedora
::Rebuild
::RPM
::flag_as_string
($pflag) .
75 # Test whole matrix of flags (5*5) for given version order
77 my ($order, @results) = @_;
80 Fedora
::Rebuild
::RPM
::LESS
,
81 Fedora
::Rebuild
::RPM
::LESS
|Fedora
::Rebuild
::RPM
::EQUAL
,
82 Fedora
::Rebuild
::RPM
::EQUAL
,
83 Fedora
::Rebuild
::RPM
::GREATER
|Fedora
::Rebuild
::RPM
::EQUAL
,
84 Fedora
::Rebuild
::RPM
::GREATER
88 for my $rflag (@flags) {
89 for my $pflag (@flags) {
90 test_matrix_cell
($order, $rflag, $pflag, $results[$i++]);
97 # (labelCompare($rversion,$pversion) = $order) == 0:
101 1, 1, 0, 0, 0, # rflag <
109 # (labelCompare($rversion,$pversion) = $order) > 0:
113 1, 1, 1, 1, 1, # rflag <
121 # (labelCompare($rversion,$pversion) = $order) < 0:
125 1, 1, 0, 0, 0, # rflag <
135 Fedora
::Rebuild
::RPM
::is_satisfied
(
136 'a', Fedora
::Rebuild
::RPM
::GREATER
|Fedora
::Rebuild
::RPM
::EQUAL
, '1',
138 'a' => [ [Fedora
::Rebuild
::RPM
::ANY
, ''] ]
144 Fedora
::Rebuild
::RPM
::is_satisfied
(
145 'a', Fedora
::Rebuild
::RPM
::GREATER
|Fedora
::Rebuild
::RPM
::EQUAL
, '1',
147 'a' => [ [Fedora
::Rebuild
::RPM
::EQUAL
, '2'] ]
153 ! Fedora
::Rebuild
::RPM
::is_satisfied
(
154 'a', Fedora
::Rebuild
::RPM
::GREATER
|Fedora
::Rebuild
::RPM
::EQUAL
, '1',
156 'a' => [ [Fedora
::Rebuild
::RPM
::EQUAL
, '0'] ]