annotate src/testdir/test_cjk_linebreak.vim @ 23057:35ba3a465deb

Added tag v8.2.2074 for changeset 57b6427c18e4d7e4c713c84528a6ee189c7b9ab0
author Bram Moolenaar <Bram@vim.org>
date Tue, 01 Dec 2020 20:15:04 +0100
parents 08940efa6b4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20719
diff changeset
1 " Test for CJK linebreak
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20719
diff changeset
2
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 scriptencoding utf-8
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
5 func Run_cjk_linebreak_after(rigorous)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 set textwidth=12
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 for punct in [
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡',
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》',
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':',
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 \ ';', '?', ']', '}']
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
12 call setline('.', '这是一个测试' .. punct.'试试 CJK 行禁则补丁。')
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 normal gqq
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
14 if a:rigorous
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
15 call assert_equal('这是一个测', getline(1))
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
16 else
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
17 call assert_equal('这是一个测试' .. punct, getline(1))
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
18 endif
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 endfor
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 func Test_cjk_linebreak_after()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 set formatoptions=croqn2mB1j
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
25 call Run_cjk_linebreak_after(0)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
28 func Test_cjk_linebreak_after_rigorous()
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
29 set formatoptions=croqn2mB1j]
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
30 call Run_cjk_linebreak_after(1)
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
31 endfunc
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 func Run_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 set textwidth=12
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 for punct in [
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔',
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 \ '〖', '〘', '〚', '(', '[', '{']
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
38 call setline('.', '这是个测试' .. punct.'试试 CJK 行禁则补丁。')
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 normal gqq
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 call assert_equal('这是个测试', getline(1))
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 endfor
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 func Test_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 set formatoptions=croqn2mB1j
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 call Run_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 func Test_cjk_linebreak_before_rigorous()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 set formatoptions=croqn2mB1j]
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 call Run_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
55 func Run_cjk_linebreak_nobetween(rigorous)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 " …… must not start a line
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call setline('.', '这是个测试……试试 CJK 行禁则补丁。')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 set textwidth=12 ambiwidth=double
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 normal gqq
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
60 if a:rigorous
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
61 call assert_equal('这是个测', getline(1))
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
62 else
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
63 call assert_equal('这是个测试……', getline(1))
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
64 endif
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 call setline('.', '这是一个测试……试试 CJK 行禁则补丁。')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 set textwidth=12 ambiwidth=double
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 normal gqq
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 call assert_equal('这是一个测', getline(1))
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 " but —— can
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 call setline('.', '这是个测试——试试 CJK 行禁则补丁。')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 set textwidth=12 ambiwidth=double
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 normal gqq
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 call assert_equal('这是个测试', getline(1))
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 func Test_cjk_linebreak_nobetween()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 set formatoptions=croqn2mB1j
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
82 call Run_cjk_linebreak_nobetween(0)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 func Test_cjk_linebreak_nobetween_rigorous()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 set formatoptions=croqn2mB1j]
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
87 call Run_cjk_linebreak_nobetween(1)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 func Test_cjk_linebreak_join_punct()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 for punct in ['——', '〗', ',', '。', '……']
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
92 call setline(1, '文本文本' .. punct)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 call setline(2, 'English')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 set formatoptions=croqn2mB1j
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 normal ggJ
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
96 call assert_equal('文本文本' .. punct.'English', getline(1))
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 endfor
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20719
diff changeset
100
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20719
diff changeset
101 " vim: shiftwidth=2 sts=2 expandtab