1 |
#!perl -w |
2 |
|
3 |
use strict; |
4 |
|
5 |
# init some vars |
6 |
my $affix_file='/usr/lib/ispell/english.aff'; |
7 |
my @test_words=( 'cars', 'dogs' ); |
8 |
|
9 |
my $findaffix_file='./findaffix.out'; |
10 |
|
11 |
my $loaded = 0; |
12 |
|
13 |
BEGIN { $| = 1; print "1..6\n"; } |
14 |
END {print "not ok 1\n" unless $loaded;} |
15 |
|
16 |
use Lingua::Spelling::Alternative; |
17 |
$loaded = 1; |
18 |
print "ok 1\n"; |
19 |
|
20 |
### test constructor |
21 |
|
22 |
my $a = new Lingua::Spelling::Alternative( DEBUG => 1 ) ; |
23 |
|
24 |
defined($a) || print 'not '; print "ok 2\n"; |
25 |
|
26 |
### test load affix |
27 |
|
28 |
if ( -e $affix_file ) { |
29 |
my $ok = $a->load_affix($affix_file); |
30 |
print 'not ' if (! $ok); |
31 |
print "ok 3\n"; |
32 |
|
33 |
my @words = $a->alternatives(@test_words); |
34 |
print 'not ' if (! @words); |
35 |
print "ok 4 # - ",join(", ",@test_words)," -> ",join(", ",@words),"\n"; |
36 |
} else { |
37 |
print "ok 3 # - Skip, affix file '$affix_file' not found\n"; |
38 |
print "ok 4 # - Skip\n"; |
39 |
} |
40 |
|
41 |
undef $a; |
42 |
|
43 |
### test load findaffix |
44 |
|
45 |
if ( -e $findaffix_file ) { |
46 |
my $a = new Lingua::Spelling::Alternative( DEBUG => 1 ) ; |
47 |
|
48 |
my $ok = $a->load_findaffix($findaffix_file); |
49 |
print 'not ' if (! $ok); |
50 |
print "ok 5\n"; |
51 |
|
52 |
my @words = $a->alternatives(@test_words); |
53 |
print 'not ' if (! @words); |
54 |
print "ok 6 # - ",join(", ",@test_words)," -> ",join(", ",@words),"\n"; |
55 |
} else { |
56 |
print "ok 5 # - Skip, findaffix file '$findaffix_file' not found\n"; |
57 |
print "ok 6 # - Skip\n"; |
58 |
} |
59 |
|