annotate src/testdir/test_cjk_linebreak.vim @ 21465:b5d4ab124782 v8.2.1283

patch 8.2.1283: Vim9: error for misplaced -> lacks argument Commit: https://github.com/vim/vim/commit/637cd7d1c9fa0ee47951ccdc310a388cb7ecfada Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 23 19:06:23 2020 +0200 patch 8.2.1283: Vim9: error for misplaced -> lacks argument Problem: Vim9: error for misplaced -> lacks argument. Solution: Use the pointer before it was advanced.
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 Jul 2020 19:15:03 +0200
parents ef2a4a650c67
children 08940efa6b4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 scriptencoding utf-8
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
3 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
4 set textwidth=12
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 for punct in [
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡',
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》',
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 \ ';', '?', ']', '}']
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
10 call setline('.', '这是一个测试' .. punct.'试试 CJK 行禁则补丁。')
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 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
12 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
13 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
14 else
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('这是一个测试' .. 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
16 endif
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 endfor
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 func Test_cjk_linebreak_after()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 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
23 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
24 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
26 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
27 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
28 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
29 endfunc
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 func Run_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 set textwidth=12
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 for punct in [
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔',
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 \ '〖', '〘', '〚', '(', '[', '{']
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
36 call setline('.', '这是个测试' .. punct.'试试 CJK 行禁则补丁。')
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 normal gqq
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 call assert_equal('这是个测试', getline(1))
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 endfor
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 func Test_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 set formatoptions=croqn2mB1j
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 call Run_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 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
49 set formatoptions=croqn2mB1j]
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 call Run_cjk_linebreak_before()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52
20719
ef2a4a650c67 patch 8.2.0912: a few test cases for CJK formatting are disabled
Bram Moolenaar <Bram@vim.org>
parents: 20695
diff changeset
53 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
54 " …… must not start a line
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 call setline('.', '这是个测试……试试 CJK 行禁则补丁。')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 set textwidth=12 ambiwidth=double
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 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
58 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
59 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
60 else
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 endif
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 call setline('.', '这是一个测试……试试 CJK 行禁则补丁。')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 set textwidth=12 ambiwidth=double
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 normal gqq
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 call assert_equal('这是一个测', getline(1))
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 " but —— can
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 call setline('.', '这是个测试——试试 CJK 行禁则补丁。')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 set textwidth=12 ambiwidth=double
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 normal gqq
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 call assert_equal('这是个测试', getline(1))
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 func Test_cjk_linebreak_nobetween()
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 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
80 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
81 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 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
84 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
85 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
86 endfunc
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 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
89 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
90 call setline(1, '文本文本' .. punct)
20695
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call setline(2, 'English')
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 set formatoptions=croqn2mB1j
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 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
94 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
95 %d_
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 endfor
cea8ae407452 patch 8.2.0901: formatting CJK text isn't optimal
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 endfunc