5a60d2367acd36fbb553c8e584586a1c09150412
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / Boolean.pm
1 # $Id: Boolean.pm,v 1.2 2006-10-25 11:25:36 sondberg Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Search::Boolean;
6
7 use 5.008;
8 use strict;
9 use warnings;
10
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
13
14
15 sub start {
16     my $class = shift();
17     my($conn) = @_;
18     my %pqfs = ('and'   => '@and @attr 1=4 mineral @attr 1=4 water',
19                 'or'    => '@or @attr 1=4 mineral @attr 1=4 water',
20                 'not'   => '@not @attr 1=4 mineral @attr 1=4 water',
21                 'and-or'=> '@and @or @attr 1=4 mineral @attr 1=4 water ' .
22                            '@attr 1=4 of' 
23                 );
24
25     foreach my $operator (keys %pqfs) {
26         $conn->irspy_search_pqf($pqfs{$operator},
27                                 {'operator' => $operator}, {},
28                                 ZOOM::Event::RECV_SEARCH, \&found,
29                                 exception => \&error);
30     }
31 }
32
33
34 sub found {
35     my($conn, $task, $test_args, $event) = @_;
36     my $operator = $test_args->{'operator'};
37     my $n = $task->{rs}->size();
38
39     $conn->log("irspy_test", "search using boolean operator ", $operator,
40                              " found $n record", $n==1 ? "" : "s");
41     $conn->record()->store_result('boolean', 'operator' => $operator,
42                                              'ok'       => 1);
43
44     return ZOOM::IRSpy::Status::TASK_DONE;
45 }
46
47
48 sub error {
49     my($conn, $task, $test_args, $exception) = @_;
50     my $operator = $test_args->{'operator'};
51
52     $conn->log("irspy_test", "search using boolean operator ", $operator,
53                              " had error: ", $exception);
54     $conn->record()->store_result('boolean', 'operator' => $operator,
55                                              'ok'       => 0);
56     return ZOOM::IRSpy::Status::TASK_DONE;
57 }
58
59
60 1;