Skip to content

Commit

Permalink
Add some vader tests for completion feature
Browse files Browse the repository at this point in the history
I want to improve file/path completion, so add some tests to cover
existing behaviour (at least existing behaviour as I understand it).
  • Loading branch information
mmrwoods committed May 6, 2022
1 parent 2e46de4 commit a49ef6c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/feature/completion.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Before:
enew!
only!
cd include/completion
let w:testing = 1

After:
cd -

Execute (command: flags, match all):
Assert len(grepper#complete('-', '', v:null)) > 3
AssertEqual count(grepper#complete('-', '', v:null), '-cword '), 1
AssertEqual count(grepper#complete('-', '', v:null), '-grepprg '), 1
AssertEqual count(grepper#complete('-', '', v:null), '-tool '), 1

Execute (command: flags, match one):
AssertEqual grepper#complete('-noquickf', '', v:null), ['-noquickfix ']

Execute (command: flags, match some):
Assert len(grepper#complete('-no', '', v:null)) > 2
AssertEqual count(grepper#complete('-no', '', v:null), '-switch '), 0
AssertEqual count(grepper#complete('-no', '', v:null), '-noswitch '), 1

Execute (command: flags, -dir options):
Assert len(grepper#complete('', 'Grepper -dir ', v:null)) > 2
AssertEqual count(grepper#complete('', 'Grepper -dir ', v:null), 'cwd '), 1
AssertEqual count(grepper#complete('', 'Grepper -dir ', v:null), 'repo '), 1

Execute (command: flags, -stop completion):
Assert grepper#complete('', 'Grepper -stop ', v:null)[0] =~# '\d\+'

Execute (command: flags, -tool options):
Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1
AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1

Execute (command: flags, -tool options):
Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1
AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1

Execute (prompt: relative path, empty string):
AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/']

Execute (prompt: relative path, whitespace only):
AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/']

Execute (prompt: sub-path, ./ exact match):
AssertEqual grepper#complete_files('x ./', v:null, v:null), ['x ./foo/']

Execute (prompt: sub-path, ./ and word chars):
AssertEqual grepper#complete_files('x ./f', v:null, v:null), ['x ./foo/']

Execute (prompt: nested sub-path, e.g. ./foo/):
AssertEqual grepper#complete_files('x ./foo/', v:null, v:null), ['x ./foo/bar/']

Execute (prompt: absolute path, / exact match):
AssertEqual count(grepper#complete_files('x /', v:null, v:null), 'x /bin/'), 1
AssertEqual count(grepper#complete_files('x /', v:null, v:null), 'x /var/'), 1

Execute (prompt: absolute path, / and word chars):
AssertEqual count(grepper#complete_files('x /b', v:null, v:null), 'x /bin/'), 1
AssertEqual count(grepper#complete_files('x /b', v:null, v:null), 'x /var/'), 0
Empty file.

0 comments on commit a49ef6c

Please sign in to comment.