Browse Source

the match function now tests as good

tags/0.0.0
Zane C. B-H 4 months ago
parent
commit
290bba0b9e
2 changed files with 13 additions and 6 deletions
  1. +3
    -3
      Net-Connection-Match/lib/Net/Connection/Match.pm
  2. +10
    -3
      Net-Connection-Match/t/Match.t

+ 3
- 3
Net-Connection-Match/lib/Net/Connection/Match.pm View File

@@ -194,12 +194,12 @@ sub match{
}

# Stores the number of hits
my $hits;
my $hits=0;
my $required=0;
foreach my $check ( @{ $self->{checks} } ){
my $hit;
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.
@@ -220,7 +220,7 @@ sub match{
}

# if these are the same, then we have a match
if ( $required == $hits ){
if ( $required eq $hits ){
return 1;
}


+ 10
- 3
Net-Connection-Match/t/Match.t 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');


# make sure it will not accept null input
eval{
$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');

# 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(5);
done_testing(6);

Loading…
Cancel
Save