/[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

Contents of /trunk/t/04words.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Sun Jul 11 20:18:25 2004 UTC (19 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 915 byte(s)
initial import into subversion of version 0.1

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 my $t = new jsFind B => 6;
21
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 "$dict/$_" => {
37 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 print STDERR " words.txt created\n";
61
62 cmp_ok($t->to_jsfind("./html"), '==', $max, " jsfind index");
63 }
64
65

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26