/[wait]/branches/unido/t/disjoint.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /branches/unido/t/disjoint.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 106 - (show annotations)
Tue Jul 13 12:22:09 2004 UTC (19 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2706 byte(s)
Changes made by Andreas J. Koenig <andreas.koenig(at)anima.de> for Unido project

1 # -*- Mode: Perl -*-
2 # scan.t --
3 # ITIID : $ITI$ $Header $__Header$
4 # Author : Ulrich Pfeifer
5 # Created On : Thu Aug 8 12:14:23 1996
6 # Last Modified By: Ulrich Pfeifer
7 # Last Modified On: Sun Nov 22 18:44:33 1998
8 # Language : CPerl
9 # Update Count : 128
10 # Status : Unknown, Use with caution!
11 #
12 # Copyright (c) 1996-1997, Ulrich Pfeifer
13 #
14
15 ######################### We start with some black magic to print on failure.
16
17 BEGIN { $| = 1; print "1..32\n"; }
18 END {print "not ok 1\n" unless $loaded;
19 system 'rm -rf test' if -d 'test';
20 }
21 #use diagnostics;
22 use WAIT::Database;
23 $loaded = 1;
24 print "ok 1\n";
25
26 ######################### End of black magic.
27
28 $test = 2;
29
30 $db = create WAIT::Database name => 'test';
31 print ((defined $db)? "ok $test\n" : "not ok $test\n"); $test++;
32
33 $tb = create_table $db name => 'sample', attr => ['docid', 'term'],
34 djk => ['docid'];
35
36 print ((defined $tb)? "ok $test\n" : "not ok $test\n"); $test++;
37
38 $etid = 1;
39 while (<DATA>) {
40 chomp;
41 my($weight, $did, $term) = split;
42 $tid = $tb->insert($weight, docid => $did, term => $term);
43 push @db, [$did, $term, $weight];
44 print (($tid == $etid++)? "ok $test\n" : "not ok $test\n"); $test++;
45 }
46
47 $sc = $tb->open_scan();
48 print ((defined $sc)? "ok $test\n" : "not ok $test\n"); $test++;
49
50 $tid = 0;
51 while (%tp = $sc->next()) {
52 printf "%s", (($tp{docid} == $db[$tid]->[0]
53 and $tp{term} eq $db[$tid]->[1])?
54 "ok $test\n" : "not ok $test\n"); $test++;
55 $tid++;
56 }
57
58 $sc = $tb->open_scan(sub {$_[0]->{term} eq 'IR'});
59 print ((defined $sc)? "ok $test\n" : "not ok $test\n"); $test++;
60
61 $tid=0;
62 @ndb = @db[1,4];
63 while (%tp = $sc->next()) {
64 printf "%s", (($tp{docid} == $ndb[$tid]->[0]
65 and $tp{term} eq $ndb[$tid]->[1])?
66 "ok $test\n" : "not ok $test\n"); $test++;
67 $tid++;
68 }
69
70 $sc = $tb->open_index_scan(['docid', 'term']);
71 print ((defined $sc)? "ok $test\n" : "not ok $test\n"); $test++;
72
73 $etid = 1;
74 while (%tp = $sc->next()) {
75 print (($tp{_id} == $etid++)?"ok $test\n" : "not ok $test\n"); $test++;
76 }
77
78 $sc = $tb->open_index_scan(['docid', 'term'], sub {$_[0]->{term} eq 'IR'});
79 print ((defined $sc)? "ok $test\n" : "not ok $test\n"); $test++;
80
81 @ndb = (1,4);
82 while (%tp = $sc->next()) {
83 print (($tp{_id} == shift(@ndb)+1)?"ok $test\n" : "not ok $test\n"); $test++;
84 }
85
86 $status = $tb->close;
87 print (($status)? "ok $test\n" : "not ok $test\n"); $test++;
88
89 # must have destroyed all handles here !
90 # clean up
91 $status = $db->dispose;
92 print (($status)? "ok $test\n" : "not ok $test\n"); $test++;
93 print ((!defined $db)? "ok $test\n" : "not ok $test\n"); $test++;
94
95 __END__
96 0.1 1 DB
97 0.2 1 IR
98 0.3 2 DB
99 0.4 2 KI
100 0.5 3 IR
101 0.6 3 KI

  ViewVC Help
Powered by ViewVC 1.1.26