/[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 43 - (hide annotations)
Sun Feb 24 20:04:59 2008 UTC (16 years, 2 months ago) by dpavlin
File MIME type: application/x-troff
File size: 933 byte(s)
fix tests

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

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26