This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The Grand Trek: move the *.t files from t/ to lib/ and ext/.
[perl5.git] / lib / Text / Abbrev.t
1 #!./perl
2
3 print "1..7\n";
4
5 BEGIN {
6     chdir 't' if -d 't';
7     @INC = '../lib';
8 }
9
10 use Text::Abbrev;
11
12 print "ok 1\n";
13
14 # old style as reference
15 local(%x);
16 my @z = qw(list edit send abort gripe listen);
17 abbrev(*x, @z);
18 my $r = join ':', sort keys %x; 
19 print "not " if exists $x{'l'}   ||
20                 exists $x{'li'}  ||
21                 exists $x{'lis'};
22 print "ok 2\n";
23
24 print "not " unless $x{'list'}   eq 'list' &&
25                     $x{'liste'}  eq 'listen' &&
26                     $x{'listen'} eq 'listen';
27 print "ok 3\n";
28
29 print "not " unless $x{'a'}     eq 'abort' &&
30                     $x{'ab'}    eq 'abort' &&
31                     $x{'abo'}   eq 'abort' &&
32                     $x{'abor'}  eq 'abort' &&
33                     $x{'abort'} eq 'abort';
34 print "ok 4\n";
35
36 my $test = 5;
37
38 # wantarray
39 my %y = abbrev @z;
40 my $s = join ':', sort keys %y;
41 print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++;
42
43 my $y = abbrev @z;
44 $s = join ':', sort keys %$y;
45 print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++;
46
47 %y = ();
48 abbrev \%y, @z;
49
50 $s = join ':', sort keys %y;
51 print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++;