Include: include/setup.vader

Execute (writegood: postprocess: length):
  function! s:F(entry)
    if !has_key(a:entry, 'col')
      let a:entry.col = 0
    endif
    call neomake#makers#ft#text#PostprocessWritegood(a:entry)
    return a:entry
  endfunction
  AssertEqual s:F({'text': '"Currently" can weaken meaning'}).length, 9
  AssertEqual s:F({'text': '"Currently" can "weaken" meaning'}).length, 9
  Assert !has_key(s:F({'text': '"Currently can weaken meaning'}), 'length')

Execute (writegood: postprocess increments column):
  function! s:F(entry)
    call neomake#makers#ft#text#PostprocessWritegood(a:entry)
    return a:entry
  endfunction
  AssertEqual s:F({'col': 2, 'text': 'foo'}), {'col': 3, 'text': 'foo'}

Execute (proselint):
  new
  file file.txt
  Save &errorformat
  let &errorformat = neomake#makers#ft#text#proselint().errorformat
  call append(0, [
  \ "file.txt:1:1: typography.symbols.ellipsis '...' is an approximation, use the ellipsis symbol '…'.",
  \ "file.txt:2:9: uncomparables.misc Comparison of an uncomparable: 'very unique.' is not comparable.",
  \ "file.txt:2:9: weasel_words.very Substitute 'damn' every time you're inclined to write 'very;' your editor will delete it and the writing will be just as it should be."])
  norm! Gdd
  lgetbuffer
  AssertEqualQf getloclist(0), [
  \ {'lnum': 1, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1,
  \  'type': 'W', 'pattern': '', 'text': 'typography.symbols.ellipsis ''...'' is an approximation, use the ellipsis symbol ''…''.'},
  \ {'lnum': 2, 'bufnr': bufnr('%'), 'col': 9, 'valid': 1, 'vcol': 0, 'nr': -1,
  \  'type': 'W', 'pattern': '', 'text': 'uncomparables.misc Comparison of an uncomparable: ''very unique.'' is not comparable.'},
  \ {'lnum': 2, 'bufnr': bufnr('%'), 'col': 9, 'valid': 1, 'vcol': 0, 'nr': -1,
  \  'type': 'W', 'pattern': '', 'text': 'weasel_words.very Substitute ''damn'' every time you''re inclined to write ''very;'' your editor will delete it and the writing will be just as it should be.'},
  \ ]

  norm! ggdGcc...

  function! s:F(entry)
    call neomake#makers#ft#text#proselint().postprocess(a:entry)
    return a:entry
  endfunction
  AssertEqual 3, s:F(getloclist(0)[0]).length

  let maker = neomake#GetMaker('proselint', 'text')
  let maker.append_file = 0
  let maker.exe = 'echo'
  let maker.args = ["file.txt:1:1: typography.symbols.ellipsis '...' is an approximation, use the ellipsis symbol '…'."]

  call neomake#highlights#ResetFile(bufnr('%'))
  call neomake#Make(1, [maker])
  NeomakeTestsWaitForFinishedJobs

  let highlights = neomake#highlights#_get()
  if has('nvim')
    Assert has_key(highlights['file'], bufnr('%'))
  else
    AssertEqual highlights, {'file': {bufnr('%'): {
    \ 'NeomakeError': [], 'NeomakeInfo': [], 'NeomakeMessage': [],
    \ 'NeomakeWarning': [[1, 1, 3]]}}, 'project': {}}
  endif
  bwipe!

Execute (writegood: handles wrapped message):
  Save &errorformat
  let &errorformat = neomake#makers#ft#text#writegood().errorformat
  lgetexpr [
  \ 'README.md:1:73:"be',
  \ 'used" may be passive voice',
  \ 'README.md:2:1:something else']

  let bufnr = bufnr('README.md')
  AssertEqualQf getloclist(0), [
  \ {'lnum': 1, 'bufnr': bufnr, 'col': 73, 'valid': 1, 'vcol': 0, 'nr': -1,
  \  'type': 'W', 'pattern': '', 'text': "\"be\nused\" may be passive voice"},
  \ {'lnum': 2, 'bufnr': bufnr, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1,
  \  'type': 'W', 'pattern': '', 'text': 'something else'}]
  exe 'bwipe' bufnr

Execute (writegood: handles empty lines):
  Save &errorformat
  let &errorformat = neomake#makers#ft#text#writegood().errorformat
  lgetexpr ['']
  AssertEqual getloclist(0), []
