diff options
author | ckelsel <ckelsel@hotmail.com> | 2018-01-14 20:52:51 +0800 |
---|---|---|
committer | ckelsel <ckelsel@hotmail.com> | 2018-01-14 20:57:27 +0800 |
commit | fe4ba6995895f95f461d40eda356cc7e1dbb1abf (patch) | |
tree | e0b9313ccd50a0df96ce9029ab1f6dd320845bef /src | |
parent | 7faeaf9f243a8b955b73960d3bba9a34fce3132d (diff) | |
download | rneovim-fe4ba6995895f95f461d40eda356cc7e1dbb1abf.tar.gz rneovim-fe4ba6995895f95f461d40eda356cc7e1dbb1abf.tar.bz2 rneovim-fe4ba6995895f95f461d40eda356cc7e1dbb1abf.zip |
vim-patch:8.0.0385: no tests for arabic
Problem: No tests for arabic.
Solution: Add a first test for arabic. (Dominique Pelle, closes vim/vim#1518)
https://github.com/vim/vim/commit/b5e8377364110ee70090274da15d202778e96a64
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/testdir/Makefile | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_arabic.vim | 92 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index a23dacba15..0c25945274 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -40,6 +40,7 @@ SCRIPTS ?= $(SCRIPTS_DEFAULT) # Tests using runtest.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS ?= \ + test_arabic.vim \ test_autocmd.res \ test_bufwintabinfo.res \ test_changedtick.res \ diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim new file mode 100644 index 0000000000..b9e033462e --- /dev/null +++ b/src/nvim/testdir/test_arabic.vim @@ -0,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\<C-^>12\<C-^>12", 'tx') + redraw + call assert_equal('١٢12١٢', getline('.')) + set arabic& + bwipe! +endfunc + +func Test_delcombine() + new + set arabic + call feedkeys("isghl\<BS>\<BS>", 'tx') + redraw + call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1)) + + " Now the same with nodelcombine + set nodelcombine + %d + call feedkeys("isghl\<BS>\<BS>", 'tx') + call assert_equal(["\nd8 b3 "], GetCharsUtf8(1)) + set arabic& + bwipe! +endfunc |