Browse Source

the match function now tests as good

tags/0.0.0
Zane C. B-H 1 month 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{
194 194
 	}
195 195
 
196 196
 	# Stores the number of hits
197
-	my $hits;
197
+	my $hits=0;
198 198
 	my $required=0;
199 199
 	foreach my $check ( @{ $self->{checks} } ){
200 200
 		my $hit;
201 201
 		eval{
202
-			$hit=$check->{check}->($conn);
202
+			$hit=$check->{check}->match($conn);
203 203
 		};
204 204
 
205 205
 		# If $hits is undef, then one of the checks errored and we skip processing the results.
@@ -220,7 +220,7 @@ sub match{
220 220
 	}
221 221
 
222 222
 	# if these are the same, then we have a match
223
-	if ( $required == $hits ){
223
+	if ( $required eq $hits ){
224 224
 		return 1;
225 225
 	}
226 226
 

+ 10
- 3
Net-Connection-Match/t/Match.t View File

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

Loading…
Cancel
Save