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