view src/testdir/test_codestyle.vim @ 31845:2ce8e7c4acf4 v9.0.1255

patch 9.0.1255: changing 'virtualedit' does not have immediate effect Commit: https://github.com/vim/vim/commit/8fe5b9c8c1223861cec0484ccc031858ae08d107 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 28 16:37:37 2023 +0000 patch 9.0.1255: changing 'virtualedit' does not have immediate effect Problem: Changing 'virtualedit' does not have immediate effect. Solution: Correct how is checked for a changed value. (closes https://github.com/vim/vim/issues/11878)
author Bram Moolenaar <Bram@vim.org>
date Sat, 28 Jan 2023 17:45:03 +0100
parents 50555279168b
children dbec60b8c253
line wrap: on
line source

" Test for checking the source code style.

def Test_source_files()
  for fname in glob('../*.[ch]', 0, 1)
    exe 'edit ' .. fname

    cursor(1, 1)
    var lnum = search(' \t')
    assert_equal(0, lnum, fname .. ': space before tab')

    cursor(1, 1)
    lnum = search('\s$')
    assert_equal(0, lnum, fname .. ': trailing white space')

    # some files don't stick to the Vim style rules
    if fname =~ 'iscygpty.c'
      continue
    endif

    # Examples in comments use "condition) {", skip them.
    # Skip if a double quote or digit comes after the "{".
    # Skip specific string used in os_unix.c.
    # Also skip fold markers.
    var skip = 'getline(".") =~ "condition) {" || getline(".") =~ "vimglob_func" || getline(".") =~ "{\"" || getline(".") =~ "{\\d" || getline(".") =~ "{{{"'
    cursor(1, 1)
    lnum = search(')\s*{', '', 0, 0, skip)
    assert_equal(0, lnum, fname .. ': curly after closing paren')

    cursor(1, 1)
    # Examples in comments use double quotes.
    skip = "getline('.') =~ '\"'"
    # Avoid examples that contain: "} else
    lnum = search('[^"]}\s*else', '', 0, 0, skip)
    assert_equal(0, lnum, fname .. ': curly before "else"')

    cursor(1, 1)
    lnum = search('else\s*{', '', 0, 0, skip)
    assert_equal(0, lnum, fname .. ': curly after "else"')
  endfor

  bwipe!
enddef


" vim: shiftwidth=2 sts=2 expandtab