To: vim_dev@googlegroups.com Subject: Patch 8.0.0385 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0385 Problem: No tests for arabic. Solution: Add a first test for arabic. (Dominique Pelle, closes #1518) Files: src/Makefile, src/testdir/Make_all.mak, src/testdir/test_arabic.vim *** ../vim-8.0.0384/src/Makefile 2017-02-25 20:40:31.762696457 +0100 --- src/Makefile 2017-02-27 21:38:03.693920587 +0100 *************** *** 2092,2097 **** --- 2092,2098 ---- # Run individual NEW style test, assuming that Vim was already compiled. test_arglist \ + test_arabic \ test_assert \ test_assign \ test_autochdir \ *** ../vim-8.0.0384/src/testdir/Make_all.mak 2017-02-25 14:20:56.784372170 +0100 --- src/testdir/Make_all.mak 2017-02-27 21:38:03.693920587 +0100 *************** *** 133,139 **** # Tests using runtest.vim.vim. # Keep test_alot*.res as the last one, sort the others. ! NEW_TESTS = test_arglist.res \ test_assert.res \ test_autochdir.res \ test_backspace_opt.res \ --- 133,140 ---- # Tests using runtest.vim.vim. # Keep test_alot*.res as the last one, sort the others. ! NEW_TESTS = test_arabic.res \ ! test_arglist.res \ test_assert.res \ test_autochdir.res \ test_backspace_opt.res \ *** ../vim-8.0.0384/src/testdir/test_arabic.vim 2017-02-27 21:47:44.373939962 +0100 --- src/testdir/test_arabic.vim 2017-02-27 21:47:12.370158836 +0100 *************** *** 0 **** --- 1,92 ---- + " Simplistic testing of Arabic mode. + + if !has('arabic') + finish + endif + + set encoding=utf-8 + scriptencoding utf-8 + + " Return list of utf8 sequences of each character at line lnum. + " Combining characters are treated as a single item. + func GetCharsUtf8(lnum) + call cursor(a:lnum, 1) + let chars = [] + let numchars = strchars(getline('.'), 1) + for i in range(1, numchars) + exe 'norm ' i . '|' + call add(chars, execute('norm g8')) + endfor + return chars + endfunc + + func Test_arabic_toggle() + set arabic + call assert_equal(1, &rightleft) + call assert_equal(1, &arabicshape) + call assert_equal('arabic', &keymap) + call assert_equal(1, &delcombine) + + set iminsert=1 imsearch=1 + set arabic& + call assert_equal(0, &rightleft) + call assert_equal(1, &arabicshape) + call assert_equal('arabic', &keymap) + call assert_equal(1, &delcombine) + call assert_equal(0, &iminsert) + call assert_equal(-1, &imsearch) + + set arabicshape& keymap= delcombine& + endfunc + + func Test_arabic_input() + new + set arabic + " Typing sghl in Arabic insert mode should show the + " Arabic word 'Salaam' i.e. 'peace'. + call feedkeys('isghl', 'tx') + redraw + call assert_equal([ + \ "\nd8 b3 ", + \ "\nd9 84 + d8 a7 ", + \ "\nd9 85 "], GetCharsUtf8(1)) + + " Without shaping, it should give individual Arabic letters. + set noarabicshape + redraw + call assert_equal([ + \ "\nd8 b3 ", + \ "\nd9 84 ", + \ "\nd8 a7 ", + \ "\nd9 85 "], GetCharsUtf8(1)) + + set arabicshape& + set arabic& + bwipe! + endfunc + + func Test_arabic_toggle_keymap() + new + set arabic + call feedkeys("i12\12\12", 'tx') + redraw + call assert_equal('١٢12١٢', getline('.')) + set arabic& + bwipe! + endfunc + + func Test_delcombine() + new + set arabic + call feedkeys("isghl\\", 'tx') + redraw + call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1)) + + " Now the same with nodelcombine + set nodelcombine + %d + call feedkeys("isghl\\", 'tx') + call assert_equal(["\nd8 b3 "], GetCharsUtf8(1)) + set arabic& + bwipe! + endfunc *** ../vim-8.0.0384/src/version.c 2017-02-27 21:35:49.618842663 +0100 --- src/version.c 2017-02-27 21:39:05.661494810 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 385, /**/ -- I'm not familiar with this proof, but I'm aware of a significant following of toddlers who believe that peanut butter is the solution to all of life's problems... -- Tim Hammerquist /// 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 ///