Mercurial > vim
annotate src/testdir/test_source.vim @ 25028:faa3de7aed8b v8.2.3051
patch 8.2.3051: Vim9: for loop with one list variable does not work
Commit: https://github.com/vim/vim/commit/444d878324525787e55185ce3c3e29a3de9b700a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 26 12:40:56 2021 +0200
patch 8.2.3051: Vim9: for loop with one list variable does not work
Problem: Vim9: for loop with one list variable does not work.
Solution: Use a separate flag for unpacking a list. (closes https://github.com/vim/vim/issues/8452)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Jun 2021 12:45:03 +0200 |
parents | c2a234e8c896 |
children | fc859aea8cec |
rev | line source |
---|---|
15442
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Tests for the :source command. |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
24287
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
3 source check.vim |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
4 source view_util.vim |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
5 |
15442
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 func Test_source_autocmd() |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 call writefile([ |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 \ 'let did_source = 1', |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 \ ], 'Xsourced') |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 au SourcePre *source* let did_source_pre = 1 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 au SourcePost *source* let did_source_post = 1 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 source Xsourced |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 call assert_equal(g:did_source, 1) |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 call assert_equal(g:did_source_pre, 1) |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 call assert_equal(g:did_source_post, 1) |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 call delete('Xsourced') |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 au! SourcePre |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 au! SourcePost |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 unlet g:did_source |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 unlet g:did_source_pre |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 unlet g:did_source_post |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 endfunc |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 func Test_source_cmd() |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 au SourceCmd *source* let did_source = expand('<afile>') |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 au SourcePre *source* let did_source_pre = 2 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 au SourcePost *source* let did_source_post = 2 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 source Xsourced |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 call assert_equal(g:did_source, 'Xsourced') |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 call assert_false(exists('g:did_source_pre')) |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 call assert_equal(g:did_source_post, 2) |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 au! SourceCmd |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 au! SourcePre |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 au! SourcePost |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 endfunc |
16726
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
42 |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
43 func Test_source_sandbox() |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
44 new |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
45 call writefile(["Ohello\<Esc>"], 'Xsourcehello') |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
46 source! Xsourcehello | echo |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
47 call assert_equal('hello', getline(1)) |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
48 call assert_fails('sandbox source! Xsourcehello', 'E48:') |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
49 bwipe! |
16920
8d91579414b8
patch 8.1.1461: tests do not run or are not reliable on some systems
Bram Moolenaar <Bram@vim.org>
parents:
16726
diff
changeset
|
50 call delete('Xsourcehello') |
16726
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
51 endfunc |
19145
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
52 |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
53 " When deleting a file and immediately creating a new one the inode may be |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
54 " recycled. Vim should not recognize it as the same script. |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
55 func Test_different_script() |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
56 call writefile(['let s:var = "asdf"'], 'XoneScript') |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
57 source XoneScript |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
58 call delete('XoneScript') |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
59 call writefile(['let g:var = s:var'], 'XtwoScript') |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
60 call assert_fails('source XtwoScript', 'E121:') |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
61 call delete('XtwoScript') |
ea3ac1de7704
patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents:
16920
diff
changeset
|
62 endfunc |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
63 |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
64 " When sourcing a vim script, shebang should be ignored. |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
65 func Test_source_ignore_shebang() |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
66 call writefile(['#!./xyzabc', 'let g:val=369'], 'Xfile.vim') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
67 source Xfile.vim |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
68 call assert_equal(g:val, 369) |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
69 call delete('Xfile.vim') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
70 endfunc |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
71 |
19425
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
72 " Test for expanding <sfile> in a autocmd and for <slnum> and <sflnum> |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
73 func Test_source_autocmd_sfile() |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
74 let code =<< trim [CODE] |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
75 let g:SfileName = '' |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
76 augroup sfiletest |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
77 au! |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
78 autocmd User UserAutoCmd let g:Sfile = '<sfile>:t' |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
79 augroup END |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
80 doautocmd User UserAutoCmd |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
81 let g:Slnum = expand('<slnum>') |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
82 let g:Sflnum = expand('<sflnum>') |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
83 augroup! sfiletest |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
84 [CODE] |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
85 call writefile(code, 'Xscript.vim') |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
86 source Xscript.vim |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
87 call assert_equal('Xscript.vim', g:Sfile) |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
88 call assert_equal('7', g:Slnum) |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
89 call assert_equal('8', g:Sflnum) |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
90 call delete('Xscript.vim') |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
91 endfunc |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
92 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
93 func Test_source_error() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
94 call assert_fails('scriptencoding utf-8', 'E167:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
95 call assert_fails('finish', 'E168:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
96 call assert_fails('scriptversion 2', 'E984:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
97 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
98 |
24287
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
99 " Test for sourcing a script recursively |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
100 func Test_nested_script() |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
101 CheckRunVimInTerminal |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
102 call writefile([':source! Xscript.vim', ''], 'Xscript.vim') |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
103 let buf = RunVimInTerminal('', {'rows': 6}) |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
104 call term_wait(buf) |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
105 call term_sendkeys(buf, ":set noruler\n") |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
106 call term_sendkeys(buf, ":source! Xscript.vim\n") |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
107 call term_wait(buf) |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
108 call WaitForAssert({-> assert_match('E22: Scripts nested too deep\s*', term_getline(buf, 6))}) |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
109 call delete('Xscript.vim') |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
110 call StopVimInTerminal(buf) |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
111 endfunc |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
112 |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
113 " vim: shiftwidth=2 sts=2 expandtab |