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