install.fairie/dotfiles/.vim/plugged/ale/test/test_parse_command_args.vader
Git E2E Dev Test Username e149692cc9 git subrepo clone https://github.com/dense-analysis/ale.git ./dotfiles/.vim/plugged/ale
subrepo:
  subdir:   "dotfiles/.vim/plugged/ale"
  merged:   "e4b205440"
upstream:
  origin:   "https://github.com/dense-analysis/ale.git"
  branch:   "master"
  commit:   "e4b205440"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
2022-10-18 10:37:09 -04:00

52 lines
1.6 KiB
Text

After:
unlet! b:parse_result
if exists(':ParseTest')
delcommand ParseTest
endif
Execute(ale#args#Parse should handle empty input):
AssertEqual
\ [{}, ''],
\ ale#args#Parse([], '')
AssertEqual
\ [{}, ''],
\ ale#args#Parse(['foo', 'bar'], '')
Execute(ale#args#Parse should parse commands correctly):
AssertEqual
\ [{'foo': '', 'bar': ''}, 'leave these alone'],
\ ale#args#Parse(['foo', 'bar'], '-foo -bar leave these alone')
AssertEqual
\ [{'foo': ''}, 'leave these alone'],
\ ale#args#Parse(['foo', 'bar'], '-foo leave these alone')
Execute(ale#args#Parse should raise errors for unknown arguments):
AssertThrows call ale#args#Parse(['foo', 'bar'], '-nope leave these alone')
AssertEqual 'Invalid argument: -nope', g:vader_exception
Execute(ale#args#Parse should stop parsing arguments after --):
AssertEqual
\ [{'foo': ''}, ' --nope leave these alone'],
\ ale#args#Parse(['foo', 'bar'], '-foo -- --nope leave these alone')
AssertEqual
\ [{}, '--'],
\ ale#args#Parse(['foo', 'bar'], '-- --')
AssertEqual
\ [{}, ''],
\ ale#args#Parse(['foo', 'bar'], '--')
Execute(ale#args#Parse should work for an example command):
command! -nargs=* ParseTest let b:parse_result = ale#args#Parse(['foo', 'bar'], <q-args>)
ParseTest
AssertEqual [{}, ''], b:parse_result
ParseTest -foo
AssertEqual [{'foo': ''}, ''], b:parse_result
ParseTest -foo -bar
AssertEqual [{'foo': '', 'bar': ''}, ''], b:parse_result
ParseTest -foo -bar leave these alone
AssertEqual [{'foo': '', 'bar': ''}, 'leave these alone'], b:parse_result