Mercurial > vim
annotate src/testdir/test_retab.vim @ 26378:a926ccd92ae1 v8.2.3720
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Commit: https://github.com/vim/vim/commit/69c76171f1a78b829196f72d7010fbe1d9ad2944
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 2 16:38:52 2021 +0000
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Problem: Vim9: Internal error when invoking closure in legacy context.
Solution: Give a more appropriate error message. (closes https://github.com/vim/vim/issues/9251)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 02 Dec 2021 17:45:03 +0100 |
parents | 4b2616ffe32b |
children | 289e87a78307 |
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 |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
10633
diff
changeset
|
2 |
10633
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 func SetUp() |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 new |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 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
|
6 endfunc |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 func TearDown() |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 bwipe! |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 endfunc |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 func Retab(bang, n) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 let l:old_tabstop = &tabstop |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 let l:old_line = getline(1) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 exe "retab" . a:bang . a:n |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 let l:line = getline(1) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 call setline(1, l:old_line) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 if a:n > 0 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 " :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
|
20 call assert_equal(a:n, &tabstop) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 exe 'set tabstop=' . l:old_tabstop |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 else |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " :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
|
24 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
|
25 endif |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 return l:line |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 endfunc |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 func Test_retab() |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 set tabstop=8 noexpandtab |
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('', '')) |
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('', 0)) |
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 c ", Retab('', 8)) |
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('!', '')) |
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('!', 0)) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 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
|
37 |
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 c ", Retab('', 4)) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 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
|
40 |
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 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
|
43 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 set tabstop=8 expandtab |
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('', '')) |
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('', 0)) |
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('', 8)) |
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('!', '')) |
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('!', 0)) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 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
|
51 |
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 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
|
54 |
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 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
|
57 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 set tabstop=4 noexpandtab |
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 c ", Retab('', '')) |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 set tabstop=4 expandtab |
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('!', '')) |
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('!', 3)) |
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 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
|
73 endfunc |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 |
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 func Test_retab_error() |
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 call assert_fails('retab! -1', 'E487:') |
25733
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
78 call assert_fails('ret -1000', 'E487:') |
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
79 call assert_fails('ret 10000', 'E475:') |
4b2616ffe32b
patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
80 call assert_fails('ret 80000000000000000000', 'E475:') |
10633
91444fa276eb
patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
10633
diff
changeset
|
82 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
10633
diff
changeset
|
83 " vim: shiftwidth=2 sts=2 expandtab |