Mercurial > vim
annotate src/testdir/test_expand_func.vim @ 17576:97a750e8707f v8.1.1785
patch 8.1.1785: map functionality mixed with character input
commit https://github.com/vim/vim/commit/b66bab381c8ba71fd6e92327d1d34c6f8a65f2a7
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 1 14:28:24 2019 +0200
patch 8.1.1785: map functionality mixed with character input
Problem: Map functionality mixed with character input.
Solution: Move the map functionality to a separate file. (Yegappan
Lakshmanan, closes #4740) Graduate the +localmap feature.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 01 Aug 2019 14:30:07 +0200 |
parents | 81be817c9d9a |
children | 73ddc462979d |
rev | line source |
---|---|
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for expand() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 let s:sfile = expand('<sfile>') |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 let s:slnum = str2nr(expand('<slnum>')) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 let s:sflnum = str2nr(expand('<sflnum>')) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 func s:expand_sfile() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 return expand('<sfile>') |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 endfunc |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 func s:expand_slnum() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 return str2nr(expand('<slnum>')) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 endfunc |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 func s:expand_sflnum() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 return str2nr(expand('<sflnum>')) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 endfunc |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 func Test_expand_sfile() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call assert_match('test_expand_func\.vim$', s:sfile) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>')) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " Call in script-local function |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_match('^function .*\.\.Test_expand_sfile\[5\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile()) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " Call in command |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 command Sfile echo expand('<sfile>') |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call assert_match('^function .*\.\.Test_expand_sfile$', trim(execute('Sfile'))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 delcommand Sfile |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 endfunc |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 func Test_expand_slnum() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call assert_equal(4, s:slnum) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call assert_equal(2, str2nr(expand('<slnum>'))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 " Line-continuation |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal( |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 \ 5, |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 \ str2nr(expand('<slnum>'))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 " Call in script-local function |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 call assert_equal(1, s:expand_slnum()) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 " Call in command |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 command Slnum echo expand('<slnum>') |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 call assert_equal(14, str2nr(trim(execute('Slnum')))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 delcommand Slnum |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 endfunc |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 func Test_expand_sflnum() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 call assert_equal(5, s:sflnum) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 call assert_equal(52, str2nr(expand('<sflnum>'))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 " Line-continuation |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 call assert_equal( |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 \ 55, |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 \ str2nr(expand('<sflnum>'))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 " Call in script-local function |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 call assert_equal(16, s:expand_sflnum()) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 " Call in command |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 command Flnum echo expand('<sflnum>') |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 call assert_equal(64, str2nr(trim(execute('Flnum')))) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 delcommand Flnum |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 endfunc |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
67 |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
68 func Test_expand() |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
69 new |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
70 call assert_equal("", expand('%:S')) |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
71 call assert_equal('3', expand('<slnum>')) |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
72 call assert_equal(['4'], expand('<slnum>', v:false, v:true)) |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
73 " Don't add any line above this, otherwise <slnum> will change. |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
74 quit |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
14700
diff
changeset
|
75 endfunc |