#!/usr/bin/perl -w
BEGIN {
use
lib File::Spec->updir;
plan(
'tests'
=> 5);
}
my
$test
= 0;
my
$err
= 0;
my
$o_base
= Perlbug::Base->new;
my
(
$BID
) =
$o_base
->get_list(
"SELECT MAX(bugid) FROM tm_id"
);
my
%matches
= (
'bugids'
=> {
"close_mac_5.5_${BID}_nocc_33"
=> [
$BID
],
"close_open_${BID}_${BID}1_nocc"
=> [
$BID
],
"close_open_1${BID}_${BID}_nocc"
=> [
$BID
],
"${BID}_nocc"
=> [
$BID
],
$BID
=> [
$BID
],
},
'changeids'
=> {
"close_mac_5.5_${BID}_x_nocc_33"
=> [
qw(33)
],
"noc_${BID}_32_x_n21occ"
=> [
qw(32)
],
"${BID}1123_88"
=> [
qw(88)
],
"nox 22222_ide atall_11_919 "
=> [
qw(11 22222 919)
],
},
'flags'
=> {
"close_mac_5.5_${BID}_nocc_33"
=> [
qw(mac close)
],
"win_onho_5.5_${BID}"
=> [
qw(win onho)
],
"${BID}_nocc_123_close"
=> [
qw(close)
],
"patch_inst"
=> [
qw(patch inst)
],
},
'versions'
=> {
"close_mac_5.5_${BID}_nocc_33"
=> [
qw(5.5)
],
"333335.5_${BID}_nocc"
=> [
qw(333335.5)
],
"close_mac_${BID}_3.4.4.4.4.4"
=> [
qw(3.4.4.4.4.4)
],
"1.2.3.4.5.6.7.8._9"
=> [
qw(1.2.3.4.5.6.7.8.)
],
},
'unknown'
=> {
"close_mac_5.5_${BID}_x_nocc_33"
=> [
qw(x nocc)
],
"noc_${BID}_x_nocc"
=> [
qw(noc x nocc)
],
"${BID}1"
=> [
"${BID}1"
],
"1${BID}"
=> [
"1${BID}"
],
"ope_cloooooooooooooose"
=> [
qw(cloooooooooooooose)
],
"nox ide atall"
=> [
qw(nox ide atall)
],
},
);
foreach
my
$context
(
sort
keys
%matches
) {
$test
++;
$err
= 0;
my
%context
= %{
$matches
{
$context
}};
foreach
my
$str
(
keys
%context
) {
my
@tgts
= @{
$context
{
$str
}};
my
%data
=
$o_base
->parse_str(
$context
{
$str
});
my
@data
= @{
$data
{
$context
}};
if
(compare(\
@data
, \
@tgts
)) {
push
(
@data
,
'x'
);
if
(compare(\
@data
, \
@tgts
)) {
$err
++;
output(
"$context failed: data(@data) should not equal (@tgts)"
);
}
}
else
{
$err
++;
output(
"$context failed: str($str) and targets(@tgts) gave data(@data)"
.Dumper(\
%data
));
}
}
if
(
$err
== 0) {
ok(
$test
);
}
else
{
notok(
$test
);
output(
"$context failed: $err errors"
);
}
}
sub
compare {
my
(
$first
,
$second
) =
@_
;
local
$^W = 0;
return
0
unless
@$first
==
@$second
;
for
(
my
$i
= 0;
$i
<
@$first
;
$i
++) {
return
0
if
$first
->[
$i
] ne
$second
->[
$i
];
}
return
1;
}