5 plan tests => ( $] ge '5.008' ? 14 : 10 );
38 use Tie::Handle; # loads Tie::StdHandle
41 open(DICT, "+>dict-$$") or die "Can't create dict-$$: $!";
42 binmode DICT; # To make length expected one.
47 my $pos = look *DICT, "Ababa";
48 chomp($word = <DICT>);
50 is $word, "Ababa", "found 'Ababa' from file";
52 if (ord('a') > ord('A') ) { # ASCII
54 $pos = look *DICT, "foo";
57 is $pos, length($DICT), "word not found will search to end of file";
59 my $pos = look *DICT, "abash";
60 chomp($word = <DICT>);
64 else { # EBCDIC systems e.g. os390
66 $pos = look *DICT, "FOO";
69 is $pos, length($DICT); # will search to end of file
71 my $pos = look *DICT, "Abba";
72 chomp($word = <DICT>);
77 $pos = look *DICT, "aarhus", 1, 1;
78 chomp($word = <DICT>);
83 close DICT or die "cannot close";
86 local $^W = 1; # turn on global warnings for stat() in Search::Dict
89 local $SIG{__WARN__} = sub { $warn = join("\n",@_) };
91 tie *DICT, 'Tie::StdHandle', "<", "dict-$$";
93 $pos = look \*DICT, "aarhus", 1, 1;
94 is( $warn, '', "no warning seen" );
99 cmp_ok $pos, ">=", 0, "case-insensitive search for 'aarhus' returned > 0";
100 is $word, "Aarhus", "case-insensitive search found 'Aarhus'";
106 if ( $] ge '5.008' ) {
107 open my $strfh, "<", \$DICT or die $!;
110 my $pos = look $strfh, 'Ababa';
111 chomp($word = <$strfh>);
112 cmp_ok $pos, ">=", 0;
117 my $pos = look $strfh, "aarhus", 1, 1;
118 chomp($word = <$strfh>);
119 cmp_ok $pos, ">=", 0;