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