Skip to content

Commit 5342f00

Browse files
committed
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.
1 parent 1159b16 commit 5342f00

File tree

2 files changed

+67
-24
lines changed

2 files changed

+67
-24
lines changed

src/testdir/test_arabic.vim

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
" Simplistic testing of Arabic mode.
22

3-
if !has('arabic')
3+
if !has('arabic') || !has('multi_byte')
44
finish
55
endif
66

7-
set encoding=utf-8
8-
scriptencoding utf-8
7+
source view_util.vim
98

10-
" Return list of utf8 sequences of each character at line lnum.
9+
" Return list of Unicode characters at line lnum.
1110
" Combining characters are treated as a single item.
12-
func GetCharsUtf8(lnum)
11+
func s:get_chars(lnum)
1312
call cursor(a:lnum, 1)
1413
let chars = []
1514
let numchars = strchars(getline('.'), 1)
1615
for i in range(1, numchars)
1716
exe 'norm ' i . '|'
18-
call add(chars, execute('norm g8'))
17+
let c=execute('ascii')
18+
let c=substitute(c, '\n\?<.\{-}Hex\s*', 'U+', 'g')
19+
let c=substitute(c, ',\s*Octal\s*\d*', '', 'g')
20+
call add(chars, c)
1921
endfor
2022
return chars
2123
endfunc
@@ -43,33 +45,36 @@ func Test_arabic_input()
4345
new
4446
set arabic
4547
" Typing sghl in Arabic insert mode should show the
46-
" Arabic word 'Salaam' i.e. 'peace'.
47-
call feedkeys('isghl', 'tx')
48-
redraw
48+
" Arabic word 'Salaam' i.e. 'peace', spelled:
49+
" SEEN, LAM, ALEF, MEEM.
50+
" See: https://www.mediawiki.org/wiki/VisualEditor/Typing/Right-to-left
51+
call feedkeys('isghl!', 'tx')
52+
call assert_match("^ *!\uFEE1\uFEFC\uFEB3$", ScreenLines(1, &columns)[0])
4953
call assert_equal([
50-
\ "\nd8 b3 ",
51-
\ "\nd9 84 + d8 a7 ",
52-
\ "\nd9 85 "], GetCharsUtf8(1))
54+
\ 'U+0633',
55+
\ 'U+0644 U+0627',
56+
\ 'U+0645',
57+
\ 'U+21'], s:get_chars(1))
5358

5459
" Without shaping, it should give individual Arabic letters.
5560
set noarabicshape
56-
redraw
61+
call assert_match("^ *!\u0645\u0627\u0644\u0633$", ScreenLines(1, &columns)[0])
5762
call assert_equal([
58-
\ "\nd8 b3 ",
59-
\ "\nd9 84 ",
60-
\ "\nd8 a7 ",
61-
\ "\nd9 85 "], GetCharsUtf8(1))
63+
\ 'U+0633',
64+
\ 'U+0644',
65+
\ 'U+0627',
66+
\ 'U+0645',
67+
\ 'U+21'], s:get_chars(1))
6268

63-
set arabicshape&
64-
set arabic&
69+
set arabic& arabicshape&
6570
bwipe!
6671
endfunc
6772

6873
func Test_arabic_toggle_keymap()
6974
new
7075
set arabic
7176
call feedkeys("i12\<C-^>12\<C-^>12", 'tx')
72-
redraw
77+
call assert_match("^ *٢١21٢١$", ScreenLines(1, &columns)[0])
7378
call assert_equal('١٢12١٢', getline('.'))
7479
set arabic&
7580
bwipe!
@@ -79,14 +84,50 @@ func Test_delcombine()
7984
new
8085
set arabic
8186
call feedkeys("isghl\<BS>\<BS>", 'tx')
82-
redraw
83-
call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1))
87+
call assert_match("^ *\uFEDE\uFEB3$", ScreenLines(1, &columns)[0])
88+
call assert_equal(['U+0633', 'U+0644'], s:get_chars(1))
8489

85-
" Now the same with nodelcombine
90+
" Now the same with 'nodelcombine'
8691
set nodelcombine
8792
%d
8893
call feedkeys("isghl\<BS>\<BS>", 'tx')
89-
call assert_equal(["\nd8 b3 "], GetCharsUtf8(1))
94+
call assert_match("^ *\uFEB1$", ScreenLines(1, &columns)[0])
95+
call assert_equal(['U+0633'], s:get_chars(1))
9096
set arabic&
9197
bwipe!
9298
endfunc
99+
100+
let s:a_YEH_HAMZA = "\u0626"
101+
let s:a_i_YEH_HAMZA = "\ufe8b"
102+
103+
let s:a_HAMZA = "\u0621"
104+
let s:a_s_HAMZA = "\ufe80"
105+
106+
let s:a_ALEF_MADDA = "\u0622"
107+
let s:a_s_ALEF_MADDA = "\ufe81"
108+
109+
let s:a_ALEF_HAMZA_ABOVE = "\u0623"
110+
let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83"
111+
112+
let s:a_GHAIN = "\u063a"
113+
let s:a_f_GHAIN = "\ufece"
114+
let s:a_s_GHAIN = "\ufecd"
115+
116+
func Test_shape_initial()
117+
new
118+
set arabicshape
119+
120+
" Shaping arabic {testchar} non-arabic Uses chg_c_a2i().
121+
" pair[0] = testchar, pair[1] = next-result, pair[2] = current-result
122+
for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA],
123+
\ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA],
124+
\ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA],
125+
\ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE],
126+
\ ]
127+
call setline(1, s:a_GHAIN . pair[0] . ' ')
128+
call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3))
129+
endfor
130+
131+
set arabicshape&
132+
bwipe!
133+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
389,
767769
/**/
768770
388,
769771
/**/

0 commit comments

Comments
 (0)