To: vim_dev@googlegroups.com Subject: Patch 8.0.0329 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0329 Problem: Xfontset and guifontwide are not tested. Solution: Add tests. (Kazunobu Kuriyama) Files: src/testdir/test_gui.vim *** ../vim-8.0.0328/src/testdir/test_gui.vim 2017-02-09 16:14:47.890179799 +0100 --- src/testdir/test_gui.vim 2017-02-12 19:53:47.124065730 +0100 *************** *** 131,136 **** --- 131,278 ---- endif endfunc + func Test_set_guifontset() + let skipped = 0 + + if has('xfontset') + let l:ctype_saved = v:ctype + + " For UTF-8 locales, XCreateFontSet(3) is likely to fail in constructing a + " fontset automatically from one or two simple XLFDs because it requires + " the host system to have a fairly comprehensive collection of fixed-width + " fonts with various sizes and registries/encodings in order to get the + " job done. To make the test meaningful for a wide variety of hosts, we + " confine ourselves to the following locale for which X11 historically has + " the fonts to use with. + language ctype ja_JP.eucJP + + " Since XCreateFontSet(3) is very sensitive to locale, fonts must be + " chosen meticulously. + let l:font_head = '-misc-fixed-medium-r-normal--14' + + let l:font_aw70 = l:font_head . '-130-75-75-c-70' + let l:font_aw140 = l:font_head . '-130-75-75-c-140' + + let l:font_jisx0201 = l:font_aw70 . '-jisx0201.1976-0' + let l:font_jisx0208 = l:font_aw140 . '-jisx0208.1983-0' + + " Full XLFDs + let l:fontset_name = join([ l:font_jisx0208, l:font_jisx0201 ], ',') + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + " XLFDs w/o CharSetRegistry and CharSetEncoding + let l:fontset_name = join([ l:font_aw140, l:font_aw70 ], ',') + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + " Singleton + let l:fontset_name = l:font_head . '-*' + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + " Aliases + let l:fontset_name = 'k14,r14' + exec 'set guifontset=' . l:fontset_name + call assert_equal(l:fontset_name, &guifontset) + + exec 'language ctype' l:ctype_saved + + else + let skipped = 1 + endif + + if skipped + throw "Skipped: Not supported by this GUI" + endif + endfunc + + func Test_set_guifontwide() + let skipped = 0 + + if has('gui_gtk') + let l:guifont_saved = &guifont + let l:guifontwide_saved = &guifontwide + + let l:fc_match = exepath('fc-match') + if l:fc_match != '' + let &guifont = system('fc-match -f "%{family[0]} %{size}" monospace:size=10') + let l:wide = system('fc-match -f "%{family[0]} %{size}" monospace:size=10:lang=ja') + exec 'set guifontwide=' . fnameescape(l:wide) + call assert_equal(l:wide, &guifontwide) + else + let skipped = 3 + endif + + let &guifontwide = l:guifontwide_saved + let &guifont = l:guifont_saved + + elseif has('gui_athena') || has('gui_motif') + " guifontwide is premised upon the xfontset feature. + if has('xfontset') + let l:encoding_saved = &encoding + let l:guifont_saved = &guifont + let l:guifontset_saved = &guifontset + let l:guifontwide_saved = &guifontwide + + let l:nfont = '-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1' + let l:wfont = '-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1' + + set encoding=utf-8 + + " Case 1: guifontset is empty + set guifontset= + + " Case 1-1: Automatic selection + set guifontwide= + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + " Case 1-2: Manual selection + exec 'set guifontwide=' . l:wfont + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + " Case 2: guifontset is invalid + try + set guifontset=-*-notexist-* + call assert_false(1, "'set guifontset=notexist' should have failed") + catch + call assert_exception('E598') + endtry + " Set it to an invalid value brutally for preparation. + let &guifontset = '-*-notexist-*' + + " Case 2-1: Automatic selection + set guifontwide= + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + " Case 2-2: Manual selection + exec 'set guifontwide=' . l:wfont + exec 'set guifont=' . l:nfont + call assert_equal(l:wfont, &guifontwide) + + let &guifontwide = l:guifontwide_saved + let &guifontset = l:guifontset_saved + let &guifont = l:guifont_saved + let &encoding = l:encoding_saved + else + let skipped = 2 + endif + else + let skipped = 1 + endif + + if skipped == 1 + throw "Skipped: Test not implemented yet for this GUI" + elseif skipped == 2 + throw "Skipped: Not supported by this GUI" + elseif skipped == 3 + throw "Skipped: Test not supported by the environment" + endif + endfunc + func Test_getwinpos() call assert_match('Window position: X \d\+, Y \d\+', execute('winpos')) call assert_true(getwinposx() >= 0) *** ../vim-8.0.0328/src/version.c 2017-02-12 18:45:19.281209607 +0100 --- src/version.c 2017-02-12 19:56:14.067031026 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 329, /**/ -- ARTHUR: Be quiet! I order you to shut up. OLD WOMAN: Order, eh -- who does he think he is? ARTHUR: I am your king! OLD WOMAN: Well, I didn't vote for you. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///