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

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

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26