blob: 447c425b27616efec414df316395f477d27b6b2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!./perl
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
print "1..3\n";
$DICT = <<EOT;
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
EOT
use Search::Dict;
open(DICT, "+>dict-$$") or die "Can't create dict-$$: $!";
binmode DICT; # To make length expected one.
print DICT $DICT;
my $pos = look *DICT, "abash";
chomp($word = <DICT>);
print "not " if $pos < 0 || $word ne "abash";
print "ok 1\n";
$pos = look *DICT, "foo";
chomp($word = <DICT>);
print "not " if $pos != length($DICT); # will search to end of file
print "ok 2\n";
$pos = look *DICT, "aarhus", 1, 1;
chomp($word = <DICT>);
print "not " if $pos < 0 || $word ne "Aarhus";
print "ok 3\n";
close DICT or die "cannot close";
unlink "dict-$$";
|