From 290bba0b9e48100dd23b6f0e0401c27550fd23a0 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Wed, 17 Jul 2019 02:40:38 -0500 Subject: [PATCH] the match function now tests as good --- Net-Connection-Match/lib/Net/Connection/Match.pm | 6 +++--- Net-Connection-Match/t/Match.t | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Net-Connection-Match/lib/Net/Connection/Match.pm b/Net-Connection-Match/lib/Net/Connection/Match.pm index b25dc2b..f3dbab6 100644 --- a/Net-Connection-Match/lib/Net/Connection/Match.pm +++ b/Net-Connection-Match/lib/Net/Connection/Match.pm @@ -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; } diff --git a/Net-Connection-Match/t/Match.t b/Net-Connection-Match/t/Match.t index 338e9b4..18fb975 100644 --- a/Net-Connection-Match/t/Match.t +++ b/Net-Connection-Match/t/Match.t @@ -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'); -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);