0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.0.0389: test for arabic does not check what is displayed

Problem:    Test for arabic does not check what is displayed.
Solution:   Improve what is asserted. (Dominique Pelle, closes #1523)
            Add a first shaping test.
This commit is contained in:
Bram Moolenaar
2017-02-28 22:51:12 +01:00
parent 1159b168dd
commit 5342f00ff9
2 changed files with 67 additions and 24 deletions

View File

@@ -1,21 +1,23 @@
" Simplistic testing of Arabic mode. " Simplistic testing of Arabic mode.
if !has('arabic') if !has('arabic') || !has('multi_byte')
finish finish
endif endif
set encoding=utf-8 source view_util.vim
scriptencoding utf-8
" Return list of utf8 sequences of each character at line lnum. " Return list of Unicode characters at line lnum.
" Combining characters are treated as a single item. " Combining characters are treated as a single item.
func GetCharsUtf8(lnum) func s:get_chars(lnum)
call cursor(a:lnum, 1) call cursor(a:lnum, 1)
let chars = [] let chars = []
let numchars = strchars(getline('.'), 1) let numchars = strchars(getline('.'), 1)
for i in range(1, numchars) for i in range(1, numchars)
exe 'norm ' i . '|' exe 'norm ' i . '|'
call add(chars, execute('norm g8')) let c=execute('ascii')
let c=substitute(c, '\n\?<.\{-}Hex\s*', 'U+', 'g')
let c=substitute(c, ',\s*Octal\s*\d*', '', 'g')
call add(chars, c)
endfor endfor
return chars return chars
endfunc endfunc
@@ -43,25 +45,28 @@ func Test_arabic_input()
new new
set arabic set arabic
" Typing sghl in Arabic insert mode should show the " Typing sghl in Arabic insert mode should show the
" Arabic word 'Salaam' i.e. 'peace'. " Arabic word 'Salaam' i.e. 'peace', spelled:
call feedkeys('isghl', 'tx') " SEEN, LAM, ALEF, MEEM.
redraw " See: https://www.mediawiki.org/wiki/VisualEditor/Typing/Right-to-left
call feedkeys('isghl!', 'tx')
call assert_match("^ *!\uFEE1\uFEFC\uFEB3$", ScreenLines(1, &columns)[0])
call assert_equal([ call assert_equal([
\ "\nd8 b3 ", \ 'U+0633',
\ "\nd9 84 + d8 a7 ", \ 'U+0644 U+0627',
\ "\nd9 85 "], GetCharsUtf8(1)) \ 'U+0645',
\ 'U+21'], s:get_chars(1))
" Without shaping, it should give individual Arabic letters. " Without shaping, it should give individual Arabic letters.
set noarabicshape set noarabicshape
redraw call assert_match("^ *!\u0645\u0627\u0644\u0633$", ScreenLines(1, &columns)[0])
call assert_equal([ call assert_equal([
\ "\nd8 b3 ", \ 'U+0633',
\ "\nd9 84 ", \ 'U+0644',
\ "\nd8 a7 ", \ 'U+0627',
\ "\nd9 85 "], GetCharsUtf8(1)) \ 'U+0645',
\ 'U+21'], s:get_chars(1))
set arabicshape& set arabic& arabicshape&
set arabic&
bwipe! bwipe!
endfunc endfunc
@@ -69,7 +74,7 @@ func Test_arabic_toggle_keymap()
new new
set arabic set arabic
call feedkeys("i12\<C-^>12\<C-^>12", 'tx') call feedkeys("i12\<C-^>12\<C-^>12", 'tx')
redraw call assert_match("^ *٢١21٢١$", ScreenLines(1, &columns)[0])
call assert_equal('١٢12١٢', getline('.')) call assert_equal('١٢12١٢', getline('.'))
set arabic& set arabic&
bwipe! bwipe!
@@ -79,14 +84,50 @@ func Test_delcombine()
new new
set arabic set arabic
call feedkeys("isghl\<BS>\<BS>", 'tx') call feedkeys("isghl\<BS>\<BS>", 'tx')
redraw call assert_match("^ *\uFEDE\uFEB3$", ScreenLines(1, &columns)[0])
call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1)) call assert_equal(['U+0633', 'U+0644'], s:get_chars(1))
" Now the same with nodelcombine " Now the same with 'nodelcombine'
set nodelcombine set nodelcombine
%d %d
call feedkeys("isghl\<BS>\<BS>", 'tx') call feedkeys("isghl\<BS>\<BS>", 'tx')
call assert_equal(["\nd8 b3 "], GetCharsUtf8(1)) call assert_match("^ *\uFEB1$", ScreenLines(1, &columns)[0])
call assert_equal(['U+0633'], s:get_chars(1))
set arabic& set arabic&
bwipe! bwipe!
endfunc endfunc
let s:a_YEH_HAMZA = "\u0626"
let s:a_i_YEH_HAMZA = "\ufe8b"
let s:a_HAMZA = "\u0621"
let s:a_s_HAMZA = "\ufe80"
let s:a_ALEF_MADDA = "\u0622"
let s:a_s_ALEF_MADDA = "\ufe81"
let s:a_ALEF_HAMZA_ABOVE = "\u0623"
let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83"
let s:a_GHAIN = "\u063a"
let s:a_f_GHAIN = "\ufece"
let s:a_s_GHAIN = "\ufecd"
func Test_shape_initial()
new
set arabicshape
" Shaping arabic {testchar} non-arabic Uses chg_c_a2i().
" pair[0] = testchar, pair[1] = next-result, pair[2] = current-result
for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA],
\ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA],
\ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA],
\ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE],
\ ]
call setline(1, s:a_GHAIN . pair[0] . ' ')
call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3))
endfor
set arabicshape&
bwipe!
endfunc

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
389,
/**/ /**/
388, 388,
/**/ /**/