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   16369 use strict;
  9         11  
  9         251  
17 9     9   32 use warnings;
  9         9  
  9         273  
18              
19             package LucyX::Search::MockMatcher;
20 9     9   29 use Lucy;
  9         10  
  9         1606  
21             our $VERSION = '0.006000_002';
22             $VERSION = eval $VERSION;
23              
24             sub new {
25 3763     3763 1 70508 my ( $either, %args ) = @_;
26 3763 50       7402 confess("Missing doc_ids") unless ref( $args{doc_ids} ) eq 'ARRAY';
27 3763         13776 my $doc_ids = Lucy::Object::I32Array->new( ints => $args{doc_ids} );
28 3763         6375 my $size = $doc_ids->get_size;
29 3763         2650 my $scores;
30 3763 100       6032 if ( ref( $args{scores} ) eq 'ARRAY' ) {
31             confess("Mismatch between scores and doc_ids array sizes")
32 3762 50       2429 unless scalar @{ $args{scores} } == $size;
  3762         6226  
33             $scores = Clownfish::Blob->new(
34 3762         4441 pack( "f$size", @{ $args{scores} } ) );
  3762         17766  
35             }
36              
37 3763         18787 return $either->_new(
38             doc_ids => $doc_ids,
39             scores => $scores,
40             );
41             }
42              
43             1;
44              
45             __END__