To: vim_dev@googlegroups.com Subject: Patch 8.2.0015 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0015 Problem: Not all modeline variants are tested. Solution: Add modeline tests. (Dominique Pelle, closes #5369) Files: src/testdir/test_modeline.vim *** ../vim-8.2.0014/src/testdir/test_modeline.vim 2019-05-26 19:02:47.000000000 +0200 --- src/testdir/test_modeline.vim 2019-12-17 19:20:41.956516303 +0100 *************** *** 7,12 **** --- 7,30 ---- set modeline call assert_fails('split Xmodeline', 'E518:') + " Missing end colon (ignored). + call writefile(['// vim: set ts=2'], 'Xmodeline') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + " Missing colon at beginning (ignored). + call writefile(['// vim set ts=2:'], 'Xmodeline') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + " Missing space after vim (ignored). + call writefile(['// vim:ts=2:'], 'Xmodeline') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + let &modeline = modeline bwipe! call delete('Xmodeline') *************** *** 60,65 **** --- 78,174 ---- set keymap= iminsert=0 imsearch=-1 endfunc + func Test_modeline_version() + let modeline = &modeline + set modeline + + " Test with vim:{vers}: (version {vers} or later). + call writefile(['// vim' .. v:version .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(2, &ts) + bwipe! + + call writefile(['// vim' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(2, &ts) + bwipe! + + call writefile(['// vim' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bw! + + " Test with vim>{vers}: (version after {vers}). + call writefile(['// vim>' .. v:version .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + call writefile(['// vim>' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(2, &ts) + bwipe! + + call writefile(['// vim>' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + " Test with vim<{vers}: (version before {vers}). + call writefile(['// vim<' .. v:version .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + call writefile(['// vim<' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + call writefile(['// vim<' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(2, &ts) + bwipe! + + " Test with vim={vers}: (version {vers} only). + call writefile(['// vim=' .. v:version .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(2, &ts) + bwipe! + + call writefile(['// vim=' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + call writefile(['// vim=' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version') + edit Xmodeline_version + call assert_equal(8, &ts) + bwipe! + + let &modeline = modeline + call delete('Xmodeline_version') + endfunc + + func Test_modeline_colon() + let modeline = &modeline + set modeline + + call writefile(['// vim: set showbreak=\: ts=2: sw=2'], 'Xmodeline_colon') + edit Xmodeline_colon + + " backlash colon should become colon. + call assert_equal(':', &showbreak) + + " 'ts' should be set. + " 'sw' should be ignored because it is after the end colon. + call assert_equal(2, &ts) + call assert_equal(8, &sw) + + let &modeline = modeline + call delete('Xmodeline_colon') + endfunc + func s:modeline_fails(what, text, error) if !exists('+' .. a:what) return *** ../vim-8.2.0014/src/version.c 2019-12-16 22:43:22.328823387 +0100 --- src/version.c 2019-12-17 19:21:55.324261129 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 15, /**/ -- Facepalm statement #9: "Did you see, there is now even a hobbit book" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///