2 # Before 'make install' is performed this script should be runnable with
3 # 'make test'. After 'make install' it should work as 'perl test.pl'
5 #########################
7 # change 'tests => 1' to 'tests => last_test_to_print';
11 BEGIN {$SIG{__WARN__} = sub { die "Terminating test due to warning: $_[0]" } };
14 BEGIN { plan tests => 8 };
17 #########################
19 # Insert your test code below, the Test module is use()ed here so read
20 # its man page ( perldoc Test ) for help writing this test script.
22 sub mset_expect_order (\@@) {
24 my @m = map { $_->get_docid() } @{$m};
25 is( scalar @m, scalar @a );
26 for my $j (0 .. (scalar @a - 1)) {
32 ok( $db = Xapian::WritableDatabase->new(), "test db opened ok" );
35 ok( $enquire = Xapian::Enquire->new( $db ), "enquire object created" );
38 ok( $doc = Xapian::Document->new() );
39 $doc->add_value(0, "A");
40 $doc->add_term("foo");
41 $db->add_document($doc);
42 $doc->add_term("foo");
43 $db->add_document($doc);
44 $doc->add_term("foo");
45 $db->add_document($doc);
46 $doc->add_term("foo");
47 $db->add_document($doc);
48 $doc->add_term("foo");
49 $db->add_document($doc);
51 $enquire->set_query(Xapian::Query->new("foo"));
54 $enquire->set_collapse_key(0);
55 my @matches = $enquire->matches(0, 3);
56 mset_expect_order(@matches, (5));
60 $enquire->set_collapse_key(0, 2);
61 my @matches = $enquire->matches(0, 3);
62 mset_expect_order(@matches, (5, 4));