/[jsFind]/trunk/t/04words.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

Annotation of /trunk/t/04words.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations)
Sun Sep 5 17:57:21 2004 UTC (19 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 919 byte(s)
version 0.04: fix bug when creating jsFind index files without first
encoding numbers in base62

1 dpavlin 1 #!/usr/bin/perl
2    
3     use strict;
4     use warnings;
5    
6     use Test::More;
7     use blib;
8     use jsFind;
9    
10     my $dict = '/usr/share/dict/words';
11    
12     if (! -r $dict) {
13     plan skip_all => "no $dict";
14     } else {
15     plan tests => 1;
16     }
17    
18     BEGIN { use_ok('jsFind'); }
19    
20 dpavlin 15 my $t = new jsFind B => 20;
21 dpavlin 1
22     my $max = 10000;
23    
24     if (-r $dict) {
25     print STDERR " making B-Tree from $max words in $dict\n";
26    
27     open(D, "$dict") || die "can't open '$dict': $!";
28    
29     my $i = 0;
30    
31     while (<D>) {
32     chomp;
33    
34     $t->B_search(Key => $_,
35     Data => {
36 dpavlin 4 "$dict" => {
37 dpavlin 1 t => "word: $_",
38     f => 1,
39     }
40     },
41     Insert => 1,
42     Append => 1,
43     );
44     $i++;
45     last if ($i > $max);
46     }
47    
48     close(D);
49    
50     if (open(T,"> words.txt")) {
51     print T $t->to_string;
52     close(T);
53     }
54     print STDERR " words.txt created\n";
55    
56     if (open(T,"> words.dot")) {
57     print T $t->to_dot;
58     close(T);
59     }
60 dpavlin 4 print STDERR " words.dot created\n";
61 dpavlin 1
62 dpavlin 4 cmp_ok($t->to_jsfind("./html/words"), '==', $max, " jsfind index");
63 dpavlin 1 }
64    
65    

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26