| 1 |
#!./perl |
| 2 |
|
| 3 |
print "1..8\n"; |
| 4 |
|
| 5 |
use Text::Abbrev; |
| 6 |
|
| 7 |
print "ok 1\n"; |
| 8 |
|
| 9 |
# old style as reference |
| 10 |
local(%x); |
| 11 |
my @z = qw(list edit send abort gripe listen); |
| 12 |
abbrev(*x, @z); |
| 13 |
my $r = join ':', sort keys %x; |
| 14 |
print "not " if exists $x{'l'} || |
| 15 |
exists $x{'li'} || |
| 16 |
exists $x{'lis'}; |
| 17 |
print "ok 2\n"; |
| 18 |
|
| 19 |
print "not " unless $x{'list'} eq 'list' && |
| 20 |
$x{'liste'} eq 'listen' && |
| 21 |
$x{'listen'} eq 'listen'; |
| 22 |
print "ok 3\n"; |
| 23 |
|
| 24 |
print "not " unless $x{'a'} eq 'abort' && |
| 25 |
$x{'ab'} eq 'abort' && |
| 26 |
$x{'abo'} eq 'abort' && |
| 27 |
$x{'abor'} eq 'abort' && |
| 28 |
$x{'abort'} eq 'abort'; |
| 29 |
print "ok 4\n"; |
| 30 |
|
| 31 |
my $test = 5; |
| 32 |
|
| 33 |
# wantarray |
| 34 |
my %y = abbrev @z; |
| 35 |
my $s = join ':', sort keys %y; |
| 36 |
print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++; |
| 37 |
|
| 38 |
my $y = abbrev @z; |
| 39 |
$s = join ':', sort keys %$y; |
| 40 |
print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++; |
| 41 |
|
| 42 |
%y = (); |
| 43 |
abbrev \%y, @z; |
| 44 |
|
| 45 |
$s = join ':', sort keys %y; |
| 46 |
print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++; |
| 47 |
|
| 48 |
|
| 49 |
# warnings safe with zero arguments |
| 50 |
my $notok; |
| 51 |
$^W = 1; |
| 52 |
$SIG{__WARN__} = sub { $notok++ }; |
| 53 |
abbrev(); |
| 54 |
print ($notok ? "not ok $test\n" : "ok $test\n"); $test++; |