/[Lingua-Spelling-Alternative]/test.pl
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 /test.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Tue Feb 12 12:41:31 2002 UTC (22 years, 1 month ago) by dpavlin
Branch: MAIN
Changes since 1.3: +45 -14 lines
File MIME type: text/plain
new minimal function which returns alternative with minimal length (it's
a poor man's version or normalizing a word)

1 dpavlin 1.1 #!perl -w
2    
3     use strict;
4    
5     # init some vars
6 dpavlin 1.4 my @affs= qw (
7     /usr/lib/ispell/english.aff
8     /usr/lib/ispell/american.aff
9     /usr/lib/ispell/british.aff
10     );
11    
12 dpavlin 1.1 my @test_words=( 'cars', 'dogs' );
13    
14 dpavlin 1.3 my $findaffix_file='./findaffix.out';
15    
16 dpavlin 1.1 my $loaded = 0;
17 dpavlin 1.4 my $debug = 0;
18 dpavlin 1.1
19 dpavlin 1.4 BEGIN { $| = 1; print "1..8\n"; }
20 dpavlin 1.1 END {print "not ok 1\n" unless $loaded;}
21    
22     use Lingua::Spelling::Alternative;
23     $loaded = 1;
24     print "ok 1\n";
25    
26     ### test constructor
27    
28 dpavlin 1.4 my $a = new Lingua::Spelling::Alternative( DEBUG => $debug ) ;
29 dpavlin 1.1
30     defined($a) || print 'not '; print "ok 2\n";
31    
32     ### test load affix
33    
34 dpavlin 1.4 my $affix_file;
35     foreach (@affs) {
36     if (-e $_) {
37     $affix_file = $_;
38     last;
39     }
40     }
41    
42     # test sub
43    
44     sub test {
45     my $nr=$_[0];
46    
47     my @words = $a->alternatives(@test_words);
48     print 'not ' if (! @words);
49     print "ok ",$nr++," # - ",join(", ",@test_words)," -> alternatives: ",join(", ",@words),"\n";
50     my @min_words = $a->minimal(@test_words);
51     print 'not ' if (! @min_words);
52     print "ok ",$nr++," # - ",join(", ",@test_words)," -> minimal: ",join(", ",@min_words),"\n";
53     }
54    
55     # skip sub
56    
57     sub skip {
58     foreach (@_) {
59     print "ok $_ # - Skip\n";
60     }
61     }
62    
63 dpavlin 1.1 if ( -e $affix_file ) {
64     my $ok = $a->load_affix($affix_file);
65     print 'not ' if (! $ok);
66     print "ok 3\n";
67 dpavlin 1.4 test(4);
68 dpavlin 1.1
69     } else {
70     print "ok 3 # - Skip, affix file '$affix_file' not found\n";
71 dpavlin 1.4 skip(4..5);
72 dpavlin 1.3 }
73    
74     undef $a;
75    
76     ### test load findaffix
77    
78     if ( -e $findaffix_file ) {
79 dpavlin 1.4 my $a = new Lingua::Spelling::Alternative( DEBUG => $debug ) ;
80 dpavlin 1.3
81     my $ok = $a->load_findaffix($findaffix_file);
82     print 'not ' if (! $ok);
83 dpavlin 1.4 print "ok 6\n";
84 dpavlin 1.3
85 dpavlin 1.4 test(7);
86 dpavlin 1.3 } else {
87 dpavlin 1.4 print "ok 6 # - Skip, findaffix file '$findaffix_file' not found\n";
88     skip(7..8);
89 dpavlin 1.1 }
90    

  ViewVC Help
Powered by ViewVC 1.1.26