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 | 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 | 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 | dpavlin | 15 | my $t = new jsFind B => 20; |
21 | dpavlin | 1 | |
22 | my $max = 10000; | ||
23 | |||
24 | if (-r $dict) { | ||
25 | dpavlin | 23 | diag "making B-Tree from $max words in $dict"; |
26 | dpavlin | 1 | |
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 | dpavlin | 4 | "$dict" => { |
37 | dpavlin | 1 | 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 | dpavlin | 23 | diag "words.txt created"; |
55 | dpavlin | 1 | |
56 | if (open(T,"> words.dot")) { | ||
57 | print T $t->to_dot; | ||
58 | close(T); | ||
59 | } | ||
60 | dpavlin | 23 | diag "words.dot created"; |
61 | dpavlin | 1 | |
62 | dpavlin | 4 | cmp_ok($t->to_jsfind("./html/words"), '==', $max, " jsfind index"); |
63 | dpavlin | 1 | } |
64 | |||
65 |
Name | Value |
---|---|
svn:executable |
ViewVC Help | |
Powered by ViewVC 1.1.26 |