comparison src/testdir/test_cjk_linebreak.vim @ 20719:ef2a4a650c67 v8.2.0912

patch 8.2.0912: a few test cases for CJK formatting are disabled Commit: https://github.com/vim/vim/commit/11f1ffd18282c44ca4b74cf7cf336da6d09e396d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 6 15:23:26 2020 +0200 patch 8.2.0912: a few test cases for CJK formatting are disabled Problem: A few test cases for CJK formatting are disabled. Solution: Fix the tests and enable them. (closes https://github.com/vim/vim/issues/6212)
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 Jun 2020 15:30:04 +0200
parents cea8ae407452
children 08940efa6b4e
comparison
equal deleted inserted replaced
20718:e1302b66410b 20719:ef2a4a650c67
1 scriptencoding utf-8 1 scriptencoding utf-8
2 2
3 func Run_cjk_linebreak_after() 3 func Run_cjk_linebreak_after(rigorous)
4 set textwidth=12 4 set textwidth=12
5 for punct in [ 5 for punct in [
6 \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡', 6 \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡',
7 \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》', 7 \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》',
8 \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':', 8 \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':',
9 \ ';', '?', ']', '}'] 9 \ ';', '?', ']', '}']
10 call setline('.', '这是一个测试'.punct.'试试 CJK 行禁则补丁。') 10 call setline('.', '这是一个测试' .. punct.'试试 CJK 行禁则补丁。')
11 normal gqq 11 normal gqq
12 call assert_equal('这是一个测试'.punct, getline(1)) 12 if a:rigorous
13 call assert_equal('这是一个测', getline(1))
14 else
15 call assert_equal('这是一个测试' .. punct, getline(1))
16 endif
13 %d_ 17 %d_
14 endfor 18 endfor
15 endfunc 19 endfunc
16 20
17 func Test_cjk_linebreak_after() 21 func Test_cjk_linebreak_after()
18 set formatoptions=croqn2mB1j 22 set formatoptions=croqn2mB1j
19 call Run_cjk_linebreak_after() 23 call Run_cjk_linebreak_after(0)
20 endfunc 24 endfunc
21 25
22 " TODO: this test fails 26 func Test_cjk_linebreak_after_rigorous()
23 "func Test_cjk_linebreak_after_rigorous() 27 set formatoptions=croqn2mB1j]
24 " set formatoptions=croqn2mB1j] 28 call Run_cjk_linebreak_after(1)
25 " call Run_cjk_linebreak_after() 29 endfunc
26 "endfunc
27 30
28 func Run_cjk_linebreak_before() 31 func Run_cjk_linebreak_before()
29 set textwidth=12 32 set textwidth=12
30 for punct in [ 33 for punct in [
31 \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔', 34 \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔',
32 \ '〖', '〘', '〚', '(', '[', '{'] 35 \ '〖', '〘', '〚', '(', '[', '{']
33 call setline('.', '这是个测试'.punct.'试试 CJK 行禁则补丁。') 36 call setline('.', '这是个测试' .. punct.'试试 CJK 行禁则补丁。')
34 normal gqq 37 normal gqq
35 call assert_equal('这是个测试', getline(1)) 38 call assert_equal('这是个测试', getline(1))
36 %d_ 39 %d_
37 endfor 40 endfor
38 endfunc 41 endfunc
45 func Test_cjk_linebreak_before_rigorous() 48 func Test_cjk_linebreak_before_rigorous()
46 set formatoptions=croqn2mB1j] 49 set formatoptions=croqn2mB1j]
47 call Run_cjk_linebreak_before() 50 call Run_cjk_linebreak_before()
48 endfunc 51 endfunc
49 52
50 func Run_cjk_linebreak_nobetween() 53 func Run_cjk_linebreak_nobetween(rigorous)
51 " …… must not start a line 54 " …… must not start a line
52 call setline('.', '这是个测试……试试 CJK 行禁则补丁。') 55 call setline('.', '这是个测试……试试 CJK 行禁则补丁。')
53 set textwidth=12 ambiwidth=double 56 set textwidth=12 ambiwidth=double
54 normal gqq 57 normal gqq
55 " TODO: this fails 58 if a:rigorous
56 " call assert_equal('这是个测试……', getline(1)) 59 call assert_equal('这是个测', getline(1))
60 else
61 call assert_equal('这是个测试……', getline(1))
62 endif
57 %d_ 63 %d_
58 64
59 call setline('.', '这是一个测试……试试 CJK 行禁则补丁。') 65 call setline('.', '这是一个测试……试试 CJK 行禁则补丁。')
60 set textwidth=12 ambiwidth=double 66 set textwidth=12 ambiwidth=double
61 normal gqq 67 normal gqq
69 call assert_equal('这是个测试', getline(1)) 75 call assert_equal('这是个测试', getline(1))
70 endfunc 76 endfunc
71 77
72 func Test_cjk_linebreak_nobetween() 78 func Test_cjk_linebreak_nobetween()
73 set formatoptions=croqn2mB1j 79 set formatoptions=croqn2mB1j
74 call Run_cjk_linebreak_nobetween() 80 call Run_cjk_linebreak_nobetween(0)
75 endfunc 81 endfunc
76 82
77 func Test_cjk_linebreak_nobetween_rigorous() 83 func Test_cjk_linebreak_nobetween_rigorous()
78 set formatoptions=croqn2mB1j] 84 set formatoptions=croqn2mB1j]
79 call Run_cjk_linebreak_nobetween() 85 call Run_cjk_linebreak_nobetween(1)
80 endfunc 86 endfunc
81 87
82 func Test_cjk_linebreak_join_punct() 88 func Test_cjk_linebreak_join_punct()
83 for punct in ['——', '〗', ',', '。', '……'] 89 for punct in ['——', '〗', ',', '。', '……']
84 call setline(1, '文本文本'.punct) 90 call setline(1, '文本文本' .. punct)
85 call setline(2, 'English') 91 call setline(2, 'English')
86 set formatoptions=croqn2mB1j 92 set formatoptions=croqn2mB1j
87 normal ggJ 93 normal ggJ
88 call assert_equal('文本文本'.punct.'English', getline(1)) 94 call assert_equal('文本文本' .. punct.'English', getline(1))
89 %d_ 95 %d_
90 endfor 96 endfor
91 endfunc 97 endfunc