Parent Directory | Revision Log
convert all print STDERR to diag, rename homer test to end with .t (woops), create homer_words.txt and homer_text.txt, preserve order when inserting into index (it doesn't really matter for index, but it's nice to have debugging output which is correct)
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 => 20; |
21 | |
22 | my $max = 10000; |
23 | |
24 | if (-r $dict) { |
25 | diag "making B-Tree from $max words in $dict"; |
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 | diag "words.txt created"; |
55 | |
56 | if (open(T,"> words.dot")) { |
57 | print T $t->to_dot; |
58 | close(T); |
59 | } |
60 | diag "words.dot created"; |
61 | |
62 | cmp_ok($t->to_jsfind("./html/words"), '==', $max, " jsfind index"); |
63 | } |
64 | |
65 |
Name | Value |
---|---|
svn:executable |
ViewVC Help | |
Powered by ViewVC 1.1.26 |