test_arabic.vim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. " Simplistic testing of Arabic mode.
  2. " NOTE: This just checks if the code works. If you know Arabic please add
  3. " functional tests that check the shaping works with real text.
  4. source check.vim
  5. CheckFeature arabic
  6. source view_util.vim
  7. " Return list of Unicode characters at line lnum.
  8. " Combining characters are treated as a single item.
  9. func s:get_chars(lnum)
  10. call cursor(a:lnum, 1)
  11. let chars = []
  12. let numchars = strchars(getline('.'), 1)
  13. for i in range(1, numchars)
  14. exe 'norm ' i . '|'
  15. let c = execute('ascii')
  16. let c = substitute(c, '\n\?<.\{-}Hex\s*', 'U+', 'g')
  17. let c = substitute(c, ',\s*Oct\(al\)\=\s\d*\(, Digr ..\)\=', '', 'g')
  18. call add(chars, c)
  19. endfor
  20. return chars
  21. endfunc
  22. func Test_arabic_toggle()
  23. set arabic
  24. call assert_equal(1, &rightleft)
  25. call assert_equal(1, &arabicshape)
  26. call assert_equal('arabic', &keymap)
  27. call assert_equal(1, &delcombine)
  28. set iminsert=1 imsearch=1
  29. set arabic&
  30. call assert_equal(0, &rightleft)
  31. call assert_equal(1, &arabicshape)
  32. call assert_equal('arabic', &keymap)
  33. call assert_equal(1, &delcombine)
  34. call assert_equal(0, &iminsert)
  35. call assert_equal(-1, &imsearch)
  36. set arabicshape& keymap= delcombine&
  37. endfunc
  38. func Test_arabic_input()
  39. new
  40. set arabic
  41. " Typing sghl in Arabic insert mode should show the
  42. " Arabic word 'Salaam' i.e. 'peace', spelled:
  43. " SEEN, LAM, ALEF, MEEM.
  44. " See: https://www.mediawiki.org/wiki/VisualEditor/Typing/Right-to-left
  45. call feedkeys('isghl!', 'tx')
  46. call assert_match("^ *!\uFEE1\uFEFC\uFEB3$", ScreenLines(1, &columns)[0])
  47. call assert_equal([
  48. \ 'U+0633',
  49. \ 'U+0644 U+0627',
  50. \ 'U+0645',
  51. \ 'U+21'], s:get_chars(1))
  52. " Without shaping, it should give individual Arabic letters.
  53. set noarabicshape
  54. call assert_match("^ *!\u0645\u0627\u0644\u0633$", ScreenLines(1, &columns)[0])
  55. call assert_equal([
  56. \ 'U+0633',
  57. \ 'U+0644',
  58. \ 'U+0627',
  59. \ 'U+0645',
  60. \ 'U+21'], s:get_chars(1))
  61. set arabic& arabicshape&
  62. bwipe!
  63. endfunc
  64. func Test_arabic_toggle_keymap()
  65. new
  66. set arabic
  67. call feedkeys("i12\<C-^>12\<C-^>12abcd", 'tx')
  68. call assert_match("^ *.*ﺷ212121$", ScreenLines(1, &columns)[0])
  69. call assert_equal('121212شلاؤي', getline('.'))
  70. set arabic&
  71. bwipe!
  72. endfunc
  73. func Test_delcombine()
  74. new
  75. set arabic
  76. call feedkeys("isghl\<BS>\<BS>", 'tx')
  77. call assert_match("^ *\uFEDE\uFEB3$", ScreenLines(1, &columns)[0])
  78. call assert_equal(['U+0633', 'U+0644'], s:get_chars(1))
  79. " Now the same with 'nodelcombine'
  80. set nodelcombine
  81. %d
  82. call feedkeys("isghl\<BS>\<BS>", 'tx')
  83. call assert_match("^ *\uFEB1$", ScreenLines(1, &columns)[0])
  84. call assert_equal(['U+0633'], s:get_chars(1))
  85. set arabic&
  86. bwipe!
  87. endfunc
  88. " Values from src/arabic.h (not all used yet)
  89. let s:a_COMMA = "\u060C"
  90. let s:a_SEMICOLON = "\u061B"
  91. let s:a_QUESTION = "\u061F"
  92. let s:a_HAMZA = "\u0621"
  93. let s:a_ALEF_MADDA = "\u0622"
  94. let s:a_ALEF_HAMZA_ABOVE = "\u0623"
  95. let s:a_WAW_HAMZA = "\u0624"
  96. let s:a_ALEF_HAMZA_BELOW = "\u0625"
  97. let s:a_YEH_HAMZA = "\u0626"
  98. let s:a_ALEF = "\u0627"
  99. let s:a_BEH = "\u0628"
  100. let s:a_TEH_MARBUTA = "\u0629"
  101. let s:a_TEH = "\u062a"
  102. let s:a_THEH = "\u062b"
  103. let s:a_JEEM = "\u062c"
  104. let s:a_HAH = "\u062d"
  105. let s:a_KHAH = "\u062e"
  106. let s:a_DAL = "\u062f"
  107. let s:a_THAL = "\u0630"
  108. let s:a_REH = "\u0631"
  109. let s:a_ZAIN = "\u0632"
  110. let s:a_SEEN = "\u0633"
  111. let s:a_SHEEN = "\u0634"
  112. let s:a_SAD = "\u0635"
  113. let s:a_DAD = "\u0636"
  114. let s:a_TAH = "\u0637"
  115. let s:a_ZAH = "\u0638"
  116. let s:a_AIN = "\u0639"
  117. let s:a_GHAIN = "\u063a"
  118. let s:a_TATWEEL = "\u0640"
  119. let s:a_FEH = "\u0641"
  120. let s:a_QAF = "\u0642"
  121. let s:a_KAF = "\u0643"
  122. let s:a_LAM = "\u0644"
  123. let s:a_MEEM = "\u0645"
  124. let s:a_NOON = "\u0646"
  125. let s:a_HEH = "\u0647"
  126. let s:a_WAW = "\u0648"
  127. let s:a_ALEF_MAKSURA = "\u0649"
  128. let s:a_YEH = "\u064a"
  129. let s:a_FATHATAN = "\u064b"
  130. let s:a_DAMMATAN = "\u064c"
  131. let s:a_KASRATAN = "\u064d"
  132. let s:a_FATHA = "\u064e"
  133. let s:a_DAMMA = "\u064f"
  134. let s:a_KASRA = "\u0650"
  135. let s:a_SHADDA = "\u0651"
  136. let s:a_SUKUN = "\u0652"
  137. let s:a_MADDA_ABOVE = "\u0653"
  138. let s:a_HAMZA_ABOVE = "\u0654"
  139. let s:a_HAMZA_BELOW = "\u0655"
  140. let s:a_ZERO = "\u0660"
  141. let s:a_ONE = "\u0661"
  142. let s:a_TWO = "\u0662"
  143. let s:a_THREE = "\u0663"
  144. let s:a_FOUR = "\u0664"
  145. let s:a_FIVE = "\u0665"
  146. let s:a_SIX = "\u0666"
  147. let s:a_SEVEN = "\u0667"
  148. let s:a_EIGHT = "\u0668"
  149. let s:a_NINE = "\u0669"
  150. let s:a_PERCENT = "\u066a"
  151. let s:a_DECIMAL = "\u066b"
  152. let s:a_THOUSANDS = "\u066c"
  153. let s:a_STAR = "\u066d"
  154. let s:a_MINI_ALEF = "\u0670"
  155. let s:a_s_FATHATAN = "\ufe70"
  156. let s:a_m_TATWEEL_FATHATAN = "\ufe71"
  157. let s:a_s_DAMMATAN = "\ufe72"
  158. let s:a_s_KASRATAN = "\ufe74"
  159. let s:a_s_FATHA = "\ufe76"
  160. let s:a_m_FATHA = "\ufe77"
  161. let s:a_s_DAMMA = "\ufe78"
  162. let s:a_m_DAMMA = "\ufe79"
  163. let s:a_s_KASRA = "\ufe7a"
  164. let s:a_m_KASRA = "\ufe7b"
  165. let s:a_s_SHADDA = "\ufe7c"
  166. let s:a_m_SHADDA = "\ufe7d"
  167. let s:a_s_SUKUN = "\ufe7e"
  168. let s:a_m_SUKUN = "\ufe7f"
  169. let s:a_s_HAMZA = "\ufe80"
  170. let s:a_s_ALEF_MADDA = "\ufe81"
  171. let s:a_f_ALEF_MADDA = "\ufe82"
  172. let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83"
  173. let s:a_f_ALEF_HAMZA_ABOVE = "\ufe84"
  174. let s:a_s_WAW_HAMZA = "\ufe85"
  175. let s:a_f_WAW_HAMZA = "\ufe86"
  176. let s:a_s_ALEF_HAMZA_BELOW = "\ufe87"
  177. let s:a_f_ALEF_HAMZA_BELOW = "\ufe88"
  178. let s:a_s_YEH_HAMZA = "\ufe89"
  179. let s:a_f_YEH_HAMZA = "\ufe8a"
  180. let s:a_i_YEH_HAMZA = "\ufe8b"
  181. let s:a_m_YEH_HAMZA = "\ufe8c"
  182. let s:a_s_ALEF = "\ufe8d"
  183. let s:a_f_ALEF = "\ufe8e"
  184. let s:a_s_BEH = "\ufe8f"
  185. let s:a_f_BEH = "\ufe90"
  186. let s:a_i_BEH = "\ufe91"
  187. let s:a_m_BEH = "\ufe92"
  188. let s:a_s_TEH_MARBUTA = "\ufe93"
  189. let s:a_f_TEH_MARBUTA = "\ufe94"
  190. let s:a_s_TEH = "\ufe95"
  191. let s:a_f_TEH = "\ufe96"
  192. let s:a_i_TEH = "\ufe97"
  193. let s:a_m_TEH = "\ufe98"
  194. let s:a_s_THEH = "\ufe99"
  195. let s:a_f_THEH = "\ufe9a"
  196. let s:a_i_THEH = "\ufe9b"
  197. let s:a_m_THEH = "\ufe9c"
  198. let s:a_s_JEEM = "\ufe9d"
  199. let s:a_f_JEEM = "\ufe9e"
  200. let s:a_i_JEEM = "\ufe9f"
  201. let s:a_m_JEEM = "\ufea0"
  202. let s:a_s_HAH = "\ufea1"
  203. let s:a_f_HAH = "\ufea2"
  204. let s:a_i_HAH = "\ufea3"
  205. let s:a_m_HAH = "\ufea4"
  206. let s:a_s_KHAH = "\ufea5"
  207. let s:a_f_KHAH = "\ufea6"
  208. let s:a_i_KHAH = "\ufea7"
  209. let s:a_m_KHAH = "\ufea8"
  210. let s:a_s_DAL = "\ufea9"
  211. let s:a_f_DAL = "\ufeaa"
  212. let s:a_s_THAL = "\ufeab"
  213. let s:a_f_THAL = "\ufeac"
  214. let s:a_s_REH = "\ufead"
  215. let s:a_f_REH = "\ufeae"
  216. let s:a_s_ZAIN = "\ufeaf"
  217. let s:a_f_ZAIN = "\ufeb0"
  218. let s:a_s_SEEN = "\ufeb1"
  219. let s:a_f_SEEN = "\ufeb2"
  220. let s:a_i_SEEN = "\ufeb3"
  221. let s:a_m_SEEN = "\ufeb4"
  222. let s:a_s_SHEEN = "\ufeb5"
  223. let s:a_f_SHEEN = "\ufeb6"
  224. let s:a_i_SHEEN = "\ufeb7"
  225. let s:a_m_SHEEN = "\ufeb8"
  226. let s:a_s_SAD = "\ufeb9"
  227. let s:a_f_SAD = "\ufeba"
  228. let s:a_i_SAD = "\ufebb"
  229. let s:a_m_SAD = "\ufebc"
  230. let s:a_s_DAD = "\ufebd"
  231. let s:a_f_DAD = "\ufebe"
  232. let s:a_i_DAD = "\ufebf"
  233. let s:a_m_DAD = "\ufec0"
  234. let s:a_s_TAH = "\ufec1"
  235. let s:a_f_TAH = "\ufec2"
  236. let s:a_i_TAH = "\ufec3"
  237. let s:a_m_TAH = "\ufec4"
  238. let s:a_s_ZAH = "\ufec5"
  239. let s:a_f_ZAH = "\ufec6"
  240. let s:a_i_ZAH = "\ufec7"
  241. let s:a_m_ZAH = "\ufec8"
  242. let s:a_s_AIN = "\ufec9"
  243. let s:a_f_AIN = "\ufeca"
  244. let s:a_i_AIN = "\ufecb"
  245. let s:a_m_AIN = "\ufecc"
  246. let s:a_s_GHAIN = "\ufecd"
  247. let s:a_f_GHAIN = "\ufece"
  248. let s:a_i_GHAIN = "\ufecf"
  249. let s:a_m_GHAIN = "\ufed0"
  250. let s:a_s_FEH = "\ufed1"
  251. let s:a_f_FEH = "\ufed2"
  252. let s:a_i_FEH = "\ufed3"
  253. let s:a_m_FEH = "\ufed4"
  254. let s:a_s_QAF = "\ufed5"
  255. let s:a_f_QAF = "\ufed6"
  256. let s:a_i_QAF = "\ufed7"
  257. let s:a_m_QAF = "\ufed8"
  258. let s:a_s_KAF = "\ufed9"
  259. let s:a_f_KAF = "\ufeda"
  260. let s:a_i_KAF = "\ufedb"
  261. let s:a_m_KAF = "\ufedc"
  262. let s:a_s_LAM = "\ufedd"
  263. let s:a_f_LAM = "\ufede"
  264. let s:a_i_LAM = "\ufedf"
  265. let s:a_m_LAM = "\ufee0"
  266. let s:a_s_MEEM = "\ufee1"
  267. let s:a_f_MEEM = "\ufee2"
  268. let s:a_i_MEEM = "\ufee3"
  269. let s:a_m_MEEM = "\ufee4"
  270. let s:a_s_NOON = "\ufee5"
  271. let s:a_f_NOON = "\ufee6"
  272. let s:a_i_NOON = "\ufee7"
  273. let s:a_m_NOON = "\ufee8"
  274. let s:a_s_HEH = "\ufee9"
  275. let s:a_f_HEH = "\ufeea"
  276. let s:a_i_HEH = "\ufeeb"
  277. let s:a_m_HEH = "\ufeec"
  278. let s:a_s_WAW = "\ufeed"
  279. let s:a_f_WAW = "\ufeee"
  280. let s:a_s_ALEF_MAKSURA = "\ufeef"
  281. let s:a_f_ALEF_MAKSURA = "\ufef0"
  282. let s:a_s_YEH = "\ufef1"
  283. let s:a_f_YEH = "\ufef2"
  284. let s:a_i_YEH = "\ufef3"
  285. let s:a_m_YEH = "\ufef4"
  286. let s:a_s_LAM_ALEF_MADDA_ABOVE = "\ufef5"
  287. let s:a_f_LAM_ALEF_MADDA_ABOVE = "\ufef6"
  288. let s:a_s_LAM_ALEF_HAMZA_ABOVE = "\ufef7"
  289. let s:a_f_LAM_ALEF_HAMZA_ABOVE = "\ufef8"
  290. let s:a_s_LAM_ALEF_HAMZA_BELOW = "\ufef9"
  291. let s:a_f_LAM_ALEF_HAMZA_BELOW = "\ufefa"
  292. let s:a_s_LAM_ALEF = "\ufefb"
  293. let s:a_f_LAM_ALEF = "\ufefc"
  294. let s:a_BYTE_ORDER_MARK = "\ufeff"
  295. func Test_shape_initial()
  296. new
  297. set arabicshape
  298. " Shaping arabic {testchar} non-arabic Tests chg_c_a2i().
  299. " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result
  300. for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA],
  301. \ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA],
  302. \ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA],
  303. \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE],
  304. \ [s:a_WAW_HAMZA, s:a_s_GHAIN, s:a_s_WAW_HAMZA],
  305. \ [s:a_ALEF_HAMZA_BELOW, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_BELOW],
  306. \ [s:a_ALEF, s:a_s_GHAIN, s:a_s_ALEF],
  307. \ [s:a_TEH_MARBUTA, s:a_s_GHAIN, s:a_s_TEH_MARBUTA],
  308. \ [s:a_DAL, s:a_s_GHAIN, s:a_s_DAL],
  309. \ [s:a_THAL, s:a_s_GHAIN, s:a_s_THAL],
  310. \ [s:a_REH, s:a_s_GHAIN, s:a_s_REH],
  311. \ [s:a_ZAIN, s:a_s_GHAIN, s:a_s_ZAIN],
  312. \ [s:a_TATWEEL, s:a_f_GHAIN, s:a_TATWEEL],
  313. \ [s:a_WAW, s:a_s_GHAIN, s:a_s_WAW],
  314. \ [s:a_ALEF_MAKSURA, s:a_s_GHAIN, s:a_s_ALEF_MAKSURA],
  315. \ [s:a_BEH, s:a_f_GHAIN, s:a_i_BEH],
  316. \ [s:a_TEH, s:a_f_GHAIN, s:a_i_TEH],
  317. \ [s:a_THEH, s:a_f_GHAIN, s:a_i_THEH],
  318. \ [s:a_JEEM, s:a_f_GHAIN, s:a_i_JEEM],
  319. \ [s:a_HAH, s:a_f_GHAIN, s:a_i_HAH],
  320. \ [s:a_KHAH, s:a_f_GHAIN, s:a_i_KHAH],
  321. \ [s:a_SEEN, s:a_f_GHAIN, s:a_i_SEEN],
  322. \ [s:a_SHEEN, s:a_f_GHAIN, s:a_i_SHEEN],
  323. \ [s:a_SAD, s:a_f_GHAIN, s:a_i_SAD],
  324. \ [s:a_DAD, s:a_f_GHAIN, s:a_i_DAD],
  325. \ [s:a_TAH, s:a_f_GHAIN, s:a_i_TAH],
  326. \ [s:a_ZAH, s:a_f_GHAIN, s:a_i_ZAH],
  327. \ [s:a_AIN, s:a_f_GHAIN, s:a_i_AIN],
  328. \ [s:a_GHAIN, s:a_f_GHAIN, s:a_i_GHAIN],
  329. \ [s:a_FEH, s:a_f_GHAIN, s:a_i_FEH],
  330. \ [s:a_QAF, s:a_f_GHAIN, s:a_i_QAF],
  331. \ [s:a_KAF, s:a_f_GHAIN, s:a_i_KAF],
  332. \ [s:a_LAM, s:a_f_GHAIN, s:a_i_LAM],
  333. \ [s:a_MEEM, s:a_f_GHAIN, s:a_i_MEEM],
  334. \ [s:a_NOON, s:a_f_GHAIN, s:a_i_NOON],
  335. \ [s:a_HEH, s:a_f_GHAIN, s:a_i_HEH],
  336. \ [s:a_YEH, s:a_f_GHAIN, s:a_i_YEH],
  337. \ ]
  338. call setline(1, s:a_GHAIN . pair[0] . ' ')
  339. call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3))
  340. endfor
  341. set arabicshape&
  342. bwipe!
  343. endfunc
  344. func Test_shape_isolated()
  345. new
  346. set arabicshape
  347. " Shaping non-arabic {testchar} non-arabic Tests chg_c_a2s().
  348. " pair[0] = testchar, pair[1] = current-result
  349. for pair in [[s:a_HAMZA, s:a_s_HAMZA],
  350. \ [s:a_ALEF_MADDA, s:a_s_ALEF_MADDA],
  351. \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_ALEF_HAMZA_ABOVE],
  352. \ [s:a_WAW_HAMZA, s:a_s_WAW_HAMZA],
  353. \ [s:a_ALEF_HAMZA_BELOW, s:a_s_ALEF_HAMZA_BELOW],
  354. \ [s:a_YEH_HAMZA, s:a_s_YEH_HAMZA],
  355. \ [s:a_ALEF, s:a_s_ALEF],
  356. \ [s:a_TEH_MARBUTA, s:a_s_TEH_MARBUTA],
  357. \ [s:a_DAL, s:a_s_DAL],
  358. \ [s:a_THAL, s:a_s_THAL],
  359. \ [s:a_REH, s:a_s_REH],
  360. \ [s:a_ZAIN, s:a_s_ZAIN],
  361. \ [s:a_TATWEEL, s:a_TATWEEL],
  362. \ [s:a_WAW, s:a_s_WAW],
  363. \ [s:a_ALEF_MAKSURA, s:a_s_ALEF_MAKSURA],
  364. \ [s:a_BEH, s:a_s_BEH],
  365. \ [s:a_TEH, s:a_s_TEH],
  366. \ [s:a_THEH, s:a_s_THEH],
  367. \ [s:a_JEEM, s:a_s_JEEM],
  368. \ [s:a_HAH, s:a_s_HAH],
  369. \ [s:a_KHAH, s:a_s_KHAH],
  370. \ [s:a_SEEN, s:a_s_SEEN],
  371. \ [s:a_SHEEN, s:a_s_SHEEN],
  372. \ [s:a_SAD, s:a_s_SAD],
  373. \ [s:a_DAD, s:a_s_DAD],
  374. \ [s:a_TAH, s:a_s_TAH],
  375. \ [s:a_ZAH, s:a_s_ZAH],
  376. \ [s:a_AIN, s:a_s_AIN],
  377. \ [s:a_GHAIN, s:a_s_GHAIN],
  378. \ [s:a_FEH, s:a_s_FEH],
  379. \ [s:a_QAF, s:a_s_QAF],
  380. \ [s:a_KAF, s:a_s_KAF],
  381. \ [s:a_LAM, s:a_s_LAM],
  382. \ [s:a_MEEM, s:a_s_MEEM],
  383. \ [s:a_NOON, s:a_s_NOON],
  384. \ [s:a_HEH, s:a_s_HEH],
  385. \ [s:a_YEH, s:a_s_YEH],
  386. \ ]
  387. call setline(1, ' ' . pair[0] . ' ')
  388. call assert_equal([' ' . pair[1] . ' '], ScreenLines(1, 3))
  389. endfor
  390. set arabicshape&
  391. bwipe!
  392. endfunc
  393. func Test_shape_iso_to_medial()
  394. new
  395. set arabicshape
  396. " Shaping arabic {testchar} arabic Tests chg_c_a2m().
  397. " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result,
  398. " pair[3] = previous-result
  399. for pair in [[s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA, s:a_s_BEH],
  400. \[s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_f_ALEF_MADDA, s:a_i_BEH],
  401. \[s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_f_ALEF_HAMZA_ABOVE, s:a_i_BEH],
  402. \[s:a_WAW_HAMZA, s:a_s_GHAIN, s:a_f_WAW_HAMZA, s:a_i_BEH],
  403. \[s:a_ALEF_HAMZA_BELOW, s:a_s_GHAIN, s:a_f_ALEF_HAMZA_BELOW, s:a_i_BEH],
  404. \[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_m_YEH_HAMZA, s:a_i_BEH],
  405. \[s:a_ALEF, s:a_s_GHAIN, s:a_f_ALEF, s:a_i_BEH],
  406. \[s:a_BEH, s:a_f_GHAIN, s:a_m_BEH, s:a_i_BEH],
  407. \[s:a_TEH_MARBUTA, s:a_s_GHAIN, s:a_f_TEH_MARBUTA, s:a_i_BEH],
  408. \[s:a_TEH, s:a_f_GHAIN, s:a_m_TEH, s:a_i_BEH],
  409. \[s:a_THEH, s:a_f_GHAIN, s:a_m_THEH, s:a_i_BEH],
  410. \[s:a_JEEM, s:a_f_GHAIN, s:a_m_JEEM, s:a_i_BEH],
  411. \[s:a_HAH, s:a_f_GHAIN, s:a_m_HAH, s:a_i_BEH],
  412. \[s:a_KHAH, s:a_f_GHAIN, s:a_m_KHAH, s:a_i_BEH],
  413. \[s:a_DAL, s:a_s_GHAIN, s:a_f_DAL, s:a_i_BEH],
  414. \[s:a_THAL, s:a_s_GHAIN, s:a_f_THAL, s:a_i_BEH],
  415. \[s:a_REH, s:a_s_GHAIN, s:a_f_REH, s:a_i_BEH],
  416. \[s:a_ZAIN, s:a_s_GHAIN, s:a_f_ZAIN, s:a_i_BEH],
  417. \[s:a_SEEN, s:a_f_GHAIN, s:a_m_SEEN, s:a_i_BEH],
  418. \[s:a_SHEEN, s:a_f_GHAIN, s:a_m_SHEEN, s:a_i_BEH],
  419. \[s:a_SAD, s:a_f_GHAIN, s:a_m_SAD, s:a_i_BEH],
  420. \[s:a_DAD, s:a_f_GHAIN, s:a_m_DAD, s:a_i_BEH],
  421. \[s:a_TAH, s:a_f_GHAIN, s:a_m_TAH, s:a_i_BEH],
  422. \[s:a_ZAH, s:a_f_GHAIN, s:a_m_ZAH, s:a_i_BEH],
  423. \[s:a_AIN, s:a_f_GHAIN, s:a_m_AIN, s:a_i_BEH],
  424. \[s:a_GHAIN, s:a_f_GHAIN, s:a_m_GHAIN, s:a_i_BEH],
  425. \[s:a_TATWEEL, s:a_f_GHAIN, s:a_TATWEEL, s:a_i_BEH],
  426. \[s:a_FEH, s:a_f_GHAIN, s:a_m_FEH, s:a_i_BEH],
  427. \[s:a_QAF, s:a_f_GHAIN, s:a_m_QAF, s:a_i_BEH],
  428. \[s:a_KAF, s:a_f_GHAIN, s:a_m_KAF, s:a_i_BEH],
  429. \[s:a_LAM, s:a_f_GHAIN, s:a_m_LAM, s:a_i_BEH],
  430. \[s:a_MEEM, s:a_f_GHAIN, s:a_m_MEEM, s:a_i_BEH],
  431. \[s:a_NOON, s:a_f_GHAIN, s:a_m_NOON, s:a_i_BEH],
  432. \[s:a_HEH, s:a_f_GHAIN, s:a_m_HEH, s:a_i_BEH],
  433. \[s:a_WAW, s:a_s_GHAIN, s:a_f_WAW, s:a_i_BEH],
  434. \[s:a_ALEF_MAKSURA, s:a_s_GHAIN, s:a_f_ALEF_MAKSURA, s:a_i_BEH],
  435. \[s:a_YEH, s:a_f_GHAIN, s:a_m_YEH, s:a_i_BEH],
  436. \ ]
  437. call setline(1, s:a_GHAIN . pair[0] . s:a_BEH)
  438. call assert_equal([pair[1] . pair[2] . pair[3]], ScreenLines(1, 3))
  439. endfor
  440. set arabicshape&
  441. bwipe!
  442. endfunc
  443. func Test_shape_final()
  444. new
  445. set arabicshape
  446. " Shaping arabic {testchar} arabic Tests chg_c_a2f().
  447. " pair[0] = testchar, pair[1] = current-result, pair[2] = previous-result
  448. for pair in [[s:a_HAMZA, s:a_s_HAMZA, s:a_s_BEH],
  449. \[s:a_ALEF_MADDA, s:a_f_ALEF_MADDA, s:a_i_BEH],
  450. \[s:a_ALEF_HAMZA_ABOVE, s:a_f_ALEF_HAMZA_ABOVE, s:a_i_BEH],
  451. \[s:a_WAW_HAMZA, s:a_f_WAW_HAMZA, s:a_i_BEH],
  452. \[s:a_ALEF_HAMZA_BELOW, s:a_f_ALEF_HAMZA_BELOW, s:a_i_BEH],
  453. \[s:a_YEH_HAMZA, s:a_f_YEH_HAMZA, s:a_i_BEH],
  454. \[s:a_ALEF, s:a_f_ALEF, s:a_i_BEH],
  455. \[s:a_BEH, s:a_f_BEH, s:a_i_BEH],
  456. \[s:a_TEH_MARBUTA, s:a_f_TEH_MARBUTA, s:a_i_BEH],
  457. \[s:a_TEH, s:a_f_TEH, s:a_i_BEH],
  458. \[s:a_THEH, s:a_f_THEH, s:a_i_BEH],
  459. \[s:a_JEEM, s:a_f_JEEM, s:a_i_BEH],
  460. \[s:a_HAH, s:a_f_HAH, s:a_i_BEH],
  461. \[s:a_KHAH, s:a_f_KHAH, s:a_i_BEH],
  462. \[s:a_DAL, s:a_f_DAL, s:a_i_BEH],
  463. \[s:a_THAL, s:a_f_THAL, s:a_i_BEH],
  464. \[s:a_REH, s:a_f_REH, s:a_i_BEH],
  465. \[s:a_ZAIN, s:a_f_ZAIN, s:a_i_BEH],
  466. \[s:a_SEEN, s:a_f_SEEN, s:a_i_BEH],
  467. \[s:a_SHEEN, s:a_f_SHEEN, s:a_i_BEH],
  468. \[s:a_SAD, s:a_f_SAD, s:a_i_BEH],
  469. \[s:a_DAD, s:a_f_DAD, s:a_i_BEH],
  470. \[s:a_TAH, s:a_f_TAH, s:a_i_BEH],
  471. \[s:a_ZAH, s:a_f_ZAH, s:a_i_BEH],
  472. \[s:a_AIN, s:a_f_AIN, s:a_i_BEH],
  473. \[s:a_GHAIN, s:a_f_GHAIN, s:a_i_BEH],
  474. \[s:a_TATWEEL, s:a_TATWEEL, s:a_i_BEH],
  475. \[s:a_FEH, s:a_f_FEH, s:a_i_BEH],
  476. \[s:a_QAF, s:a_f_QAF, s:a_i_BEH],
  477. \[s:a_KAF, s:a_f_KAF, s:a_i_BEH],
  478. \[s:a_LAM, s:a_f_LAM, s:a_i_BEH],
  479. \[s:a_MEEM, s:a_f_MEEM, s:a_i_BEH],
  480. \[s:a_NOON, s:a_f_NOON, s:a_i_BEH],
  481. \[s:a_HEH, s:a_f_HEH, s:a_i_BEH],
  482. \[s:a_WAW, s:a_f_WAW, s:a_i_BEH],
  483. \[s:a_ALEF_MAKSURA, s:a_f_ALEF_MAKSURA, s:a_i_BEH],
  484. \[s:a_YEH, s:a_f_YEH, s:a_i_BEH],
  485. \ ]
  486. call setline(1, ' ' . pair[0] . s:a_BEH)
  487. call assert_equal([' ' . pair[1] . pair[2]], ScreenLines(1, 3))
  488. endfor
  489. set arabicshape&
  490. bwipe!
  491. endfunc
  492. func Test_shape_combination_final()
  493. new
  494. set arabicshape
  495. " Shaping arabic {testchar} arabic Tests chg_c_laa2f().
  496. " pair[0] = testchar, pair[1] = current-result
  497. for pair in [[s:a_ALEF_MADDA, s:a_f_LAM_ALEF_MADDA_ABOVE],
  498. \ [s:a_ALEF_HAMZA_ABOVE, s:a_f_LAM_ALEF_HAMZA_ABOVE],
  499. \ [s:a_ALEF_HAMZA_BELOW, s:a_f_LAM_ALEF_HAMZA_BELOW],
  500. \ [s:a_ALEF, s:a_f_LAM_ALEF],
  501. \ ]
  502. " The test char is a composing char, put on s:a_LAM.
  503. call setline(1, ' ' . s:a_LAM . pair[0] . s:a_BEH)
  504. call assert_equal([' ' . pair[1] . s:a_i_BEH], ScreenLines(1, 3))
  505. endfor
  506. set arabicshape&
  507. bwipe!
  508. endfunc
  509. func Test_shape_combination_isolated()
  510. new
  511. set arabicshape
  512. " Shaping arabic {testchar} arabic Tests chg_c_laa2i().
  513. " pair[0] = testchar, pair[1] = current-result
  514. for pair in [[s:a_ALEF_MADDA, s:a_s_LAM_ALEF_MADDA_ABOVE],
  515. \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_LAM_ALEF_HAMZA_ABOVE],
  516. \ [s:a_ALEF_HAMZA_BELOW, s:a_s_LAM_ALEF_HAMZA_BELOW],
  517. \ [s:a_ALEF, s:a_s_LAM_ALEF],
  518. \ ]
  519. " The test char is a composing char, put on s:a_LAM.
  520. call setline(1, ' ' . s:a_LAM . pair[0] . ' ')
  521. call assert_equal([' ' . pair[1] . ' '], ScreenLines(1, 3))
  522. endfor
  523. set arabicshape&
  524. bwipe!
  525. endfunc
  526. " Test for entering arabic character in a search command
  527. func Test_arabic_chars_in_search_cmd()
  528. new
  529. set arabic
  530. call feedkeys("i\nsghl!\<C-^>vim\<C-^>", 'tx')
  531. call cursor(1, 1)
  532. call feedkeys("/^sghl!\<C-^>vim$\<C-^>\<CR>", 'tx')
  533. call assert_equal([2, 1], [line('.'), col('.')])
  534. " Try searching in left-to-right mode
  535. set rightleftcmd=
  536. call cursor(1, 1)
  537. call feedkeys("/^sghl!\<C-^>vim$\<CR>", 'tx')
  538. call assert_equal([2, 1], [line('.'), col('.')])
  539. set rightleftcmd&
  540. set rightleft&
  541. set arabic&
  542. bwipe!
  543. endfunc
  544. " vim: shiftwidth=2 sts=2 expandtab