robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

dundargoctest: move oldtests to test directory (#22536)af23d17388

master
2.8 KiB97 linesraw
1scriptencoding utf-8
2
3func Run_cjk_linebreak_after(rigorous)
4  set textwidth=12
5  for punct in [
6        \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡',
7        \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》',
8        \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':',
9        \ ';', '?', ']', '}']
10    call setline('.', '这是一个测试' .. punct.'试试 CJK 行禁则补丁。')
11    normal gqq
12    if a:rigorous
13      call assert_equal('这是一个测', getline(1))
14    else
15      call assert_equal('这是一个测试' .. punct, getline(1))
16    endif
17    %d_
18  endfor
19endfunc
20
21func Test_cjk_linebreak_after()
22  set formatoptions=croqn2mB1j
23  call Run_cjk_linebreak_after(0)
24endfunc
25
26func Test_cjk_linebreak_after_rigorous()
27 set formatoptions=croqn2mB1j]
28 call Run_cjk_linebreak_after(1)
29endfunc
30
31func Run_cjk_linebreak_before()
32  set textwidth=12
33  for punct in [
34        \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔',
35        \ '〖', '〘', '〚', '(', '[', '{']
36    call setline('.', '这是个测试' .. punct.'试试 CJK 行禁则补丁。')
37    normal gqq
38    call assert_equal('这是个测试', getline(1))
39    %d_
40  endfor
41endfunc
42
43func Test_cjk_linebreak_before()
44  set formatoptions=croqn2mB1j
45  call Run_cjk_linebreak_before()
46endfunc
47
48func Test_cjk_linebreak_before_rigorous()
49  set formatoptions=croqn2mB1j]
50  call Run_cjk_linebreak_before()
51endfunc
52
53func Run_cjk_linebreak_nobetween(rigorous)
54  " …… must not start a line
55  call setline('.', '这是个测试……试试 CJK 行禁则补丁。')
56  set textwidth=12 ambiwidth=double
57  normal gqq
58  if a:rigorous
59    call assert_equal('这是个测', getline(1))
60  else
61    call assert_equal('这是个测试……', getline(1))
62  endif
63  %d_
64
65  call setline('.', '这是一个测试……试试 CJK 行禁则补丁。')
66  set textwidth=12 ambiwidth=double
67  normal gqq
68  call assert_equal('这是一个测', getline(1))
69  %d_
70
71  " but —— can
72  call setline('.', '这是个测试——试试 CJK 行禁则补丁。')
73  set textwidth=12 ambiwidth=double
74  normal gqq
75  call assert_equal('这是个测试', getline(1))
76endfunc
77
78func Test_cjk_linebreak_nobetween()
79  set formatoptions=croqn2mB1j
80  call Run_cjk_linebreak_nobetween(0)
81endfunc
82
83func Test_cjk_linebreak_nobetween_rigorous()
84  set formatoptions=croqn2mB1j]
85  call Run_cjk_linebreak_nobetween(1)
86endfunc
87
88func Test_cjk_linebreak_join_punct()
89  for punct in ['——', '〗', ',', '。', '……']
90    call setline(1, '文本文本' .. punct)
91    call setline(2, 'English')
92    set formatoptions=croqn2mB1j
93    normal ggJ
94    call assert_equal('文本文本' .. punct.'English', getline(1))
95    %d_
96  endfor
97endfunc