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

Diff of /trunk/t/04words.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 15 by dpavlin, Sun Sep 5 17:57:21 2004 UTC revision 43 by dpavlin, Sun Feb 24 20:04:59 2008 UTC
# Line 7  use Test::More; Line 7  use Test::More;
7  use blib;  use blib;
8  use jsFind;  use jsFind;
9    
10  my $dict = '/usr/share/dict/words';  my $dict;
11    
12  if (! -r $dict) {  BEGIN {
13          plan skip_all => "no $dict";          $dict = '/usr/share/dict/words';
 } else {  
         plan tests => 1;  
 }  
14    
15  BEGIN { use_ok('jsFind'); }          if (! -r $dict) {
16                    plan skip_all => "no $dict";
17            } else {
18                    plan tests => 2;
19            }
20    
21            use_ok('jsFind');
22    }
23    
24  my $t = new jsFind B => 20;  my $t = new jsFind B => 20;
25    
26  my $max = 10000;  my $max = 10000;
27    
28  if (-r $dict) {  if (-r $dict) {
29          print STDERR " making B-Tree from $max words in $dict\n";          diag "making B-Tree from $max words in $dict";
30    
31          open(D, "$dict") || die "can't open '$dict': $!";          open(D, "$dict") || die "can't open '$dict': $!";
32    
# Line 31  if (-r $dict) { Line 35  if (-r $dict) {
35          while (<D>) {          while (<D>) {
36                  chomp;                  chomp;
37    
38                    next unless (/^\w+$/);
39    
40                  $t->B_search(Key => $_,                  $t->B_search(Key => $_,
41                          Data => {                          Data => {
42                                  "$dict" => {                                  "$dict" => {
# Line 42  if (-r $dict) { Line 48  if (-r $dict) {
48                          Append => 1,                          Append => 1,
49                  );                  );
50                  $i++;                  $i++;
51                  last if ($i > $max);                  last if ($i >= $max);
52          }          }
53    
54          close(D);          close(D);
# Line 51  if (-r $dict) { Line 57  if (-r $dict) {
57                  print T $t->to_string;                  print T $t->to_string;
58                  close(T);                  close(T);
59          }          }
60          print STDERR " words.txt created\n";          diag "words.txt created";
61    
62          if (open(T,"> words.dot")) {          if (open(T,"> words.dot")) {
63                  print T $t->to_dot;                  print T $t->to_dot;
64                  close(T);                  close(T);
65          }          }
66          print STDERR " words.dot created\n";          diag "words.dot created";
67    
68          cmp_ok($t->to_jsfind("./html/words"), '==', $max, " jsfind index");          cmp_ok($t->to_jsfind(dir=>"./html/words"), '==', $max, " jsfind index");
69  }  }
70    
71    

Legend:
Removed from v.15  
changed lines
  Added in v.43

  ViewVC Help
Powered by ViewVC 1.1.26