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