File Coverage

blib/lib/LucyX/Search/MockMatcher.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 6 66.6
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             # Licensed to the Apache Software Foundation (ASF) under one or more
2             # contributor license agreements. See the NOTICE file distributed with
3             # this work for additional information regarding copyright ownership.
4             # The ASF licenses this file to You under the Apache License, Version 2.0
5             # (the "License"); you may not use this file except in compliance with
6             # the License. You may obtain a copy of the License at
7             #
8             # http://www.apache.org/licenses/LICENSE-2.0
9             #
10             # Unless required by applicable law or agreed to in writing, software
11             # distributed under the License is distributed on an "AS IS" BASIS,
12             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13             # See the License for the specific language governing permissions and
14             # limitations under the License.
15              
16 9     9   16755 use strict;
  9         11  
  9         217  
17 9     9   28 use warnings;
  9         9  
  9         268  
18              
19             package LucyX::Search::MockMatcher;
20 9     9   27 use Lucy;
  9         10  
  9         1598  
21             our $VERSION = '0.006000_001';
22             $VERSION = eval $VERSION;
23              
24             sub new {
25 3763     3763 1 78240 my ( $either, %args ) = @_;
26 3763 50       6863 confess("Missing doc_ids") unless ref( $args{doc_ids} ) eq 'ARRAY';
27 3763         13004 my $doc_ids = Lucy::Object::I32Array->new( ints => $args{doc_ids} );
28 3763         6116 my $size = $doc_ids->get_size;
29 3763         2628 my $scores;
30 3763 100       5752 if ( ref( $args{scores} ) eq 'ARRAY' ) {
31             confess("Mismatch between scores and doc_ids array sizes")
32 3762 50       2280 unless scalar @{ $args{scores} } == $size;
  3762         6069  
33             $scores = Clownfish::Blob->new(
34 3762         4036 pack( "f$size", @{ $args{scores} } ) );
  3762         16960  
35             }
36              
37 3763         17979 return $either->_new(
38             doc_ids => $doc_ids,
39             scores => $scores,
40             );
41             }
42              
43             1;
44              
45             __END__