annotate src/testdir/test_retab.vim @ 15478:051937ebaf22 v8.1.0747

patch 8.1.0747: map() with a bad expression doesn't give an error commit https://github.com/vim/vim/commit/ce9d50df07402cb8e196537a9c4505845adecabc Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 14 22:22:29 2019 +0100 patch 8.1.0747: map() with a bad expression doesn't give an error Problem: map() with a bad expression doesn't give an error. (Ingo Karkat) Solution: Check for giving an error message. (closes https://github.com/vim/vim/issues/3800)
author Bram Moolenaar <Bram@vim.org>
date Mon, 14 Jan 2019 22:30:07 +0100
parents 91444fa276eb
children 08940efa6b4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10633
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test :retab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 func SetUp()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 new
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 call setline(1, "\ta \t b c ")
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func TearDown()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 bwipe!
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 func Retab(bang, n)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 let l:old_tabstop = &tabstop
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 let l:old_line = getline(1)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 exe "retab" . a:bang . a:n
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let l:line = getline(1)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call setline(1, l:old_line)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 if a:n > 0
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 " :retab changes 'tabstop' to n with argument n > 0.
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal(a:n, &tabstop)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 exe 'set tabstop=' . l:old_tabstop
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 else
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " :retab does not change 'tabstop' with empty or n <= 0.
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(l:old_tabstop, &tabstop)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endif
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 return l:line
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 func Test_retab()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 set tabstop=8 noexpandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_equal("\ta\t b c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal("\ta\t b c ", Retab('', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal("\ta\t b c ", Retab('', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal("\ta\t b\t c\t ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_equal("\ta\t b\t c\t ", Retab('!', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal("\ta\t b\t c\t ", Retab('!', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal("\t\ta\t\t\tb c ", Retab('', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal("\t\ta\t\t\tb\t\t c\t ", Retab('!', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal(" a\t\tb c ", Retab('', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call assert_equal(" a\t\tb c ", Retab('!', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 set tabstop=8 expandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal(" a b c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_equal(" a b c ", Retab('', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal(" a b c ", Retab('', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal(" a b c ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal(" a b c ", Retab('!', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal(" a b c ", Retab('!', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 call assert_equal(" a b c ", Retab(' ', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal(" a b c ", Retab('!', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call assert_equal(" a b c ", Retab(' ', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal(" a b c ", Retab('!', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 set tabstop=4 noexpandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal("\ta\t\tb c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal("\ta\t\tb\t\t c\t ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_equal("\t a\t\t\tb c ", Retab('', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call assert_equal("\t a\t\t\tb\t\t\tc\t ", Retab('!', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call assert_equal(" a\t b c ", Retab('', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal(" a\t b\t\t c\t ", Retab('!', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 set tabstop=4 expandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call assert_equal(" a b c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 call assert_equal(" a b c ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call assert_equal(" a b c ", Retab('', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call assert_equal(" a b c ", Retab('!', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call assert_equal(" a b c ", Retab('', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 call assert_equal(" a b c ", Retab('!', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 func Test_retab_error()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 call assert_fails('retab -1', 'E487:')
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call assert_fails('retab! -1', 'E487:')
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 endfunc