Changeset 4fbc7f5 for t


Ignore:
Timestamp:
Jul 29, 2009, 9:41:44 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
747d6a5
Parents:
e711ca7
git-author:
Nelson Elhage <nelhage@mit.edu> (07/29/09 21:30:43)
git-committer:
Nelson Elhage <nelhage@mit.edu> (07/29/09 21:41:44)
Message:
complete_flags: Pass the completer the argument number being completed

This is the index of the argument (not flag or flag option) being
completed, for convenience.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • t/completion.t

    re711ca7 r4fbc7f5  
    146146    my $after = shift;
    147147    my $words = shift;
     148    my $complete = shift || \&complete_zwrite;
    148149   
    149150    my $ctx = BarnOwl::Completion::Context->new($before, $after);
     
    151152    local $Test::Builder::Level = $Test::Builder::Level + 1;
    152153
    153     my @got = complete_zwrite($ctx);
     154    my @got = $complete->($ctx);
    154155    is_deeply([sort @got], [sort @$words]);
    155156}
     
    170171              [qw(nelhage asedeno geofft)]);
    171172
     173sub complete_word {
     174    my $ctx = shift;
     175    return complete_flags($ctx,
     176                          [qw(-a -b -c)],
     177                          {
     178                              "-d" => sub {qw(some words for completing)},
     179                          },
     180                          sub {$_[1]});
     181}
     182
     183test_complete('cmd -a -d foo -c hello ','',
     184              [qw(-a -b -c -d 1)], \&complete_word);
     185
     186test_complete('cmd -a -d foo -c ','',
     187              [qw(-a -b -c -d 0)], \&complete_word);
     188
    1721891;
    173190
Note: See TracChangeset for help on using the changeset viewer.