/[jsFind]/trunk/t/10homer.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/10homer.t

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

revision 25 by dpavlin, Thu Oct 7 17:30:03 2004 UTC revision 28 by dpavlin, Thu Oct 7 22:47:39 2004 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use warnings;  use warnings;
5    
6  use Test::More tests => 5;  use Test::More tests => 7;
7  use blib;  use blib;
8  use jsFind;  use jsFind;
9  use Data::Dumper;  use Data::Dumper;
# Line 16  ok(-e "t/homer.txt", "Homer: The Odyssey Line 16  ok(-e "t/homer.txt", "Homer: The Odyssey
16    
17  my $line = 0;  my $line = 0;
18  my $text = '';  my $text = '';
19  my %words;  my %words_usage;
20  my $word_count = 0;  my $word_count = 0;
21  my $max_words = 10;  my $max_words;
22    #$max_words = 100;
23    
24  my $res;  my $res;
25    
# Line 44  while(<U>) { Line 45  while(<U>) {
45    
46                  next if ($word eq '');                  next if ($word eq '');
47    
48                  $words{$word} += $usage{$word};                  $words_usage{"$word $line"} = $usage{$word};
49    
50                  $res->{$word}->{$line} = $usage{$word};                  $res->{$word}->{$line} = $usage{$word};
51    
# Line 73  while(<U>) { Line 74  while(<U>) {
74  my $test_data = Dumper($res);  my $test_data = Dumper($res);
75  $test_data =~ s/=>/:/gs;  $test_data =~ s/=>/:/gs;
76  $test_data =~ s/\$VAR1/var test_data/;  $test_data =~ s/\$VAR1/var test_data/;
77  open(JS, "> html/test_data.js") || die "can't open test_data.js: $!";  ok(open(JS, "> html/test_data.js"), "test_data.js");
78  print JS $test_data;  print JS $test_data;
79  close(JS);  close(JS);
80    
81  ok($test_data, "test_data saved");  ok($test_data, "test_data saved");
82    
83  #my $sum = 0;  my $sum = 0;
84  #foreach my $w (keys %words) {  ok(open(TD, "> homer_freq.txt"), "homer_freq.txt");
85  #       print STDERR "$w: $words{$w}\n";  foreach my $w (keys %words_usage) {
86  #       $sum += $words{$w};          print TD "$w: $words_usage{$w}\n";
87  #}          $sum += $words_usage{$w};
88    }
89    close(TD);
90    diag "homer_freq.txt created";
91    
92  if (open(T,"> homer_text.txt")) {  if (open(T,"> homer_text.txt")) {
93          print T $full_text;          print T $full_text;
# Line 97  if (open(T,"> homer_words.txt")) { Line 101  if (open(T,"> homer_words.txt")) {
101  }  }
102  diag "homer_words.txt created";  diag "homer_words.txt created";
103    
104  my $total_words = scalar keys %words;  my $total_words = scalar keys %words_usage;
105    
106  cmp_ok($t->to_jsfind("./html/homer"), '==', $total_words, " jsfind index with $total_words words");  cmp_ok($t->to_jsfind("./html/homer"), '==', $total_words, " jsfind index with $total_words words");
107    
108  print Dumper($t);  #print Dumper($t);

Legend:
Removed from v.25  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26