]> granicus.if.org Git - vim/commitdiff
patch 8.0.0385: no tests for arabic v8.0.0385
authorBram Moolenaar <Bram@vim.org>
Mon, 27 Feb 2017 20:48:26 +0000 (21:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 27 Feb 2017 20:48:26 +0000 (21:48 +0100)
Problem:    No tests for arabic.
Solution:   Add a first test for arabic. (Dominique Pelle, closes #1518)

src/Makefile
src/testdir/Make_all.mak
src/testdir/test_arabic.vim [new file with mode: 0644]
src/version.c

index 09adb9a2bc34bcf029a39079f623af64918a791a..0bdd1d470c8dc5a61d186c856437d144bcce452b 100644 (file)
@@ -2092,6 +2092,7 @@ test1 \
 
 # Run individual NEW style test, assuming that Vim was already compiled.
 test_arglist \
+       test_arabic \
        test_assert \
        test_assign \
        test_autochdir \
index 18dfdc8e7478358a4b4fac72c8c2421529d054b0..513fd897176c32d46c0991b44708ea2a61aa838e 100644 (file)
@@ -133,7 +133,8 @@ SCRIPTS_GUI =
 
 # Tests using runtest.vim.vim.
 # Keep test_alot*.res as the last one, sort the others.
-NEW_TESTS = test_arglist.res \
+NEW_TESTS = test_arabic.res \
+           test_arglist.res \
            test_assert.res \
            test_autochdir.res \
            test_backspace_opt.res \
diff --git a/src/testdir/test_arabic.vim b/src/testdir/test_arabic.vim
new file mode 100644 (file)
index 0000000..b9e0334
--- /dev/null
@@ -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
index 713b54c2b99f322cf3ca0dcc87e61d696a933715..4479cc2168fbfe2eab03e15e9fff59c86d417103 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    385,
 /**/
     384,
 /**/