Line | |
---|
1 | #!./perl
|
---|
2 |
|
---|
3 | print "1..8\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++;
|
---|
52 |
|
---|
53 |
|
---|
54 | # warnings safe with zero arguments
|
---|
55 | my $notok;
|
---|
56 | $^W = 1;
|
---|
57 | $SIG{__WARN__} = sub { $notok++ };
|
---|
58 | abbrev();
|
---|
59 | print ($notok ? "not ok $test\n" : "ok $test\n"); $test++;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.