annotate src/testdir/test_expand_func.vim @ 20169:bd970e6fa5d4

Added tag v8.2.0639 for changeset be661435893a4211d8360b4475cf80cf6ddbc53f
author Bram Moolenaar <Bram@vim.org>
date Sat, 25 Apr 2020 17:15:04 +0200
parents 546bdeef35f1
children 7449921216bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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'))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
71 call assert_equal('3', '<slnum>'->expand())
16668
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
19603
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
76
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
77 " Test for 'wildignore' with expand()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
78 func Test_expand_wildignore()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
79 set wildignore=*.vim
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
80 call assert_equal('', expand('test_expand_func.vim'))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
81 call assert_equal('', expand('test_expand_func.vim', 0))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
82 call assert_equal([], expand('test_expand_func.vim', 0, 1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
83 call assert_equal('test_expand_func.vim', expand('test_expand_func.vim', 1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
84 call assert_equal(['test_expand_func.vim'],
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
85 \ expand('test_expand_func.vim', 1, 1))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
86 call assert_fails("call expand('*', [])", 'E745:')
19603
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
87 set wildignore&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
88 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
89
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
90 " vim: shiftwidth=2 sts=2 expandtab