the match function now tests as good

This commit is contained in:
Zane C. B-H 2019-07-17 02:40:38 -05:00
parent 6fcfbb57d7
commit 290bba0b9e
2 changed files with 13 additions and 6 deletions

View File

@ -194,12 +194,12 @@ sub match{
} }
# Stores the number of hits # Stores the number of hits
my $hits; my $hits=0;
my $required=0; my $required=0;
foreach my $check ( @{ $self->{checks} } ){ foreach my $check ( @{ $self->{checks} } ){
my $hit; my $hit;
eval{ eval{
$hit=$check->{check}->($conn); $hit=$check->{check}->match($conn);
}; };
# If $hits is undef, then one of the checks errored and we skip processing the results. # If $hits is undef, then one of the checks errored and we skip processing the results.
@ -220,7 +220,7 @@ sub match{
} }
# if these are the same, then we have a match # if these are the same, then we have a match
if ( $required == $hits ){ if ( $required eq $hits ){
return 1; return 1;
} }

View File

@ -63,11 +63,18 @@ eval{
}; };
ok( $checker->error eq '2', 'match improper ref check') or diag('match accepted a ref other than Net::Connection'); ok( $checker->error eq '2', 'match improper ref check') or diag('match accepted a ref other than Net::Connection');
# make sure it will not accept null input # make sure it will not accept null input
eval{ eval{
$returned=$checker->match(); $returned=$checker->match();
}; };
ok( $checker->error eq '2', 'match null input check') or diag('match accepted a ref other than Net::Connection'); ok( $checker->error eq '2', 'match null input check') or diag('match accepted null input');
done_testing(5); # Create a connection with a matching general port and see if it matches
my $conn=Net::Connection->new( $connection_args );
$returned=0;
eval{
$returned=$checker->match($conn);
};
ok( $returned eq '1', 'match good conn check') or diag('match failed on a connection that should match');
done_testing(6);