Mercurial > vim
annotate src/testdir/test_source.vim @ 34780:54890be01c00 v9.1.0265
patch 9.1.0265: console dialog cannot save unnamed buffers
Commit: https://github.com/vim/vim/commit/df46115fc839c8912ed60646e86a412e5180ba1d
Author: glepnir <glephunter@gmail.com>
Date: Thu Apr 4 22:23:29 2024 +0200
patch 9.1.0265: console dialog cannot save unnamed buffers
Problem: console dialog cannot save unnamed buffers
Solution: set bufname before save (glepnir). Define dialog_con_gui
to test for GUI+Console dialog support, use it to skip
the test when the GUI feature has been defined.
Note: The dialog_changed() function will also try to call the
browse_save_fname() function, when FEAT_BROWSE is defined (which is only
defined in a GUI build of Vim). This will eventually lead to a call of
do_browse(), which causes an error message if a GUI is not currently
running (see the TODO: in do_browse()) and will then lead to a failure
in Test_goto_buf_with_onfirm().
Therefore, we must disable the Test_goto_buf_with_onfirm(), when the
dialog_con_gui feature is enabled (which basically means dialog feature
for GUI and Console builds, in contrast to the dialog_con and dialog_gui
feature).
(Previously this wasn't a problem, because the test aborted in the YES
case for the :confirm :b XgotoConf case and did therefore not run into
the browse function call)
closes: #14398
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 04 Apr 2024 23:45:02 +0200 |
parents | ae10b91ac6b3 |
children |
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', |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
9 \ ], 'Xsourced', 'D') |
15442
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 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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 endfunc |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 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
|
32 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 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
|
34 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
|
35 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
|
36 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 endfunc |
16726
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
41 |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
42 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
|
43 new |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
44 call writefile(["Ohello\<Esc>"], 'Xsourcehello', 'D') |
16726
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 bwipe! |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
49 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
|
50 |
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
|
51 " 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
|
52 " 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
|
53 func Test_different_script() |
30769
ae10b91ac6b3
patch 9.0.0719: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30556
diff
changeset
|
54 call writefile(['let s:var = "asdf"'], 'XoneScript', 'D') |
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
|
55 source XoneScript |
30769
ae10b91ac6b3
patch 9.0.0719: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30556
diff
changeset
|
56 call writefile(['let g:var = s:var'], 'XtwoScript', 'D') |
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
|
57 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
|
58 endfunc |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
59 |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
60 " 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
|
61 func Test_source_ignore_shebang() |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
62 call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim', 'D') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
28903
diff
changeset
|
63 source Xsisfile.vim |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
64 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
|
65 endfunc |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
66 |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
24287
diff
changeset
|
67 " Test for expanding <sfile> in an autocmd and for <slnum> and <sflnum> |
19425
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
68 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
|
69 let code =<< trim [CODE] |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
70 let g:SfileName = '' |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
71 augroup sfiletest |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
72 au! |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
73 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
|
74 augroup END |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
75 doautocmd User UserAutoCmd |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
76 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
|
77 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
|
78 augroup! sfiletest |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
79 [CODE] |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
80 call writefile(code, 'Xscript.vim', 'D') |
19425
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
81 source Xscript.vim |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
82 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
|
83 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
|
84 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
|
85 endfunc |
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
86 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
87 func Test_source_error() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
88 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
|
89 call assert_fails('finish', 'E168:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
90 call assert_fails('scriptversion 2', 'E984:') |
28139
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
91 call assert_fails('source!', 'E471:') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
92 new |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
93 call setline(1, ['', '', '', '']) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
94 call assert_fails('1,3source Xscript.vim', 'E481:') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
95 call assert_fails('1,3source! Xscript.vim', 'E481:') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
96 bw! |
19950
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 |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
102 call writefile([':source! Xscript.vim', ''], 'Xscript.vim', 'D') |
24287
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 StopVimInTerminal(buf) |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
110 endfunc |
c2a234e8c896
patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
111 |
28139
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
112 " Test for sourcing a script from the current buffer |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
113 func Test_source_buffer() |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
114 new |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
115 " Source a simple script |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
116 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
117 let a = "Test" |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
118 let b = 20 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
119 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
120 let c = [1.1] |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
121 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
122 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
123 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
124 call assert_equal(['Test', 20, [1.1]], [g:a, g:b, g:c]) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
125 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
126 " Source a range of lines in the current buffer |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
127 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
128 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
129 let a = 10 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
130 let a += 20 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
131 let a += 30 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
132 let a += 40 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
133 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
134 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
135 .source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
136 call assert_equal(10, g:a) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
137 3source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
138 call assert_equal(40, g:a) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
139 2,3source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
140 call assert_equal(90, g:a) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
141 |
28158
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
142 " Make sure the script line number is correct when sourcing a range of |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
143 " lines. |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
144 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
145 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
146 Line 1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
147 Line 2 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
148 func Xtestfunc() |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
149 return expand("<sflnum>") |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
150 endfunc |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
151 Line 3 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
152 Line 4 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
153 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
154 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
155 3,5source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
156 call assert_equal('4', Xtestfunc()) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
157 delfunc Xtestfunc |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
158 |
28139
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
159 " Source a script with line continuation lines |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
160 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
161 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
162 let m = [ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
163 \ 1, |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
164 \ 2, |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
165 \ ] |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
166 call add(m, 3) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
167 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
168 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
169 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
170 call assert_equal([1, 2, 3], g:m) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
171 " Source a script with line continuation lines and a comment |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
172 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
173 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
174 let m = [ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
175 "\ first entry |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
176 \ 'a', |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
177 "\ second entry |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
178 \ 'b', |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
179 \ ] |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
180 " third entry |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
181 call add(m, 'c') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
182 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
183 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
184 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
185 call assert_equal(['a', 'b', 'c'], g:m) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
186 " Source an incomplete line continuation line |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
187 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
188 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
189 let k = [ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
190 \ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
191 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
192 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
193 call assert_fails('source', 'E697:') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
194 " Source a function with a for loop |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
195 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
196 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
197 let m = [] |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
198 " test function |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
199 func! Xtest() |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
200 for i in range(5, 7) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
201 call add(g:m, i) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
202 endfor |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
203 endfunc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
204 call Xtest() |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
205 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
206 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
207 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
208 call assert_equal([5, 6, 7], g:m) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
209 " Source an empty buffer |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
210 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
211 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
212 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
213 " test for script local functions and variables |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
214 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
215 let s:var1 = 10 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
216 func s:F1() |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
217 let s:var1 += 1 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
218 return s:var1 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
219 endfunc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
220 func s:F2() |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
221 endfunc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
222 let g:ScriptID = expand("<SID>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
223 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
224 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
225 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
226 call assert_true(g:ScriptID != '') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
227 call assert_true(exists('*' .. g:ScriptID .. 'F1')) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
228 call assert_true(exists('*' .. g:ScriptID .. 'F2')) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
229 call assert_equal(11, call(g:ScriptID .. 'F1', [])) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
230 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
231 " the same script ID should be used even if the buffer is sourced more than |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
232 " once |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
233 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
234 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
235 let g:ScriptID = expand("<SID>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
236 let g:Count += 1 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
237 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
238 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
239 let g:Count = 0 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
240 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
241 call assert_true(g:ScriptID != '') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
242 let scid = g:ScriptID |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
243 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
244 call assert_equal(scid, g:ScriptID) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
245 call assert_equal(2, g:Count) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
246 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
247 call assert_equal(scid, g:ScriptID) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
248 call assert_equal(3, g:Count) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
249 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
250 " test for the script line number |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
251 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
252 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
253 " comment |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
254 let g:Slnum1 = expand("<slnum>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
255 let i = 1 + |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
256 \ 2 + |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
257 "\ comment |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
258 \ 3 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
259 let g:Slnum2 = expand("<slnum>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
260 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
261 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
262 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
263 call assert_equal('2', g:Slnum1) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
264 call assert_equal('7', g:Slnum2) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
265 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
266 " test for retaining the same script number across source calls |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
267 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
268 let g:ScriptID1 = expand("<SID>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
269 let g:Slnum1 = expand("<slnum>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
270 let l =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
271 let g:Slnum2 = expand("<slnum>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
272 let g:ScriptID2 = expand("<SID>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
273 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
274 new |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
275 call setline(1, l) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
276 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
277 bw! |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
278 let g:ScriptID3 = expand("<SID>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
279 let g:Slnum3 = expand("<slnum>") |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
280 END |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
281 call writefile(lines, 'Xscript', 'D') |
28139
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
282 source Xscript |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
283 call assert_true(g:ScriptID1 != g:ScriptID2) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
284 call assert_equal(g:ScriptID1, g:ScriptID3) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
285 call assert_equal('2', g:Slnum1) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
286 call assert_equal('1', g:Slnum2) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
287 call assert_equal('12', g:Slnum3) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
288 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
289 " test for sourcing a heredoc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
290 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
291 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
292 let a = 1 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
293 let heredoc =<< trim DATA |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
294 red |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
295 green |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
296 blue |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
297 DATA |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
298 let b = 2 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
299 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
300 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
301 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
302 call assert_equal(['red', ' green', 'blue'], g:heredoc) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
303 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
304 " test for a while and for statement |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
305 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
306 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
307 let a = 0 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
308 let b = 1 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
309 while b <= 10 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
310 let a += 10 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
311 let b += 1 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
312 endwhile |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
313 for i in range(5) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
314 let a += 10 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
315 endfor |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
316 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
317 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
318 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
319 call assert_equal(150, g:a) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
320 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
321 " test for sourcing the same buffer multiple times after changing a function |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
322 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
323 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
324 func Xtestfunc() |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
325 return "one" |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
326 endfunc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
327 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
328 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
329 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
330 call assert_equal("one", Xtestfunc()) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
331 call setline(2, ' return "two"') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
332 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
333 call assert_equal("two", Xtestfunc()) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
334 call setline(2, ' return "three"') |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
335 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
336 call assert_equal("three", Xtestfunc()) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
337 delfunc Xtestfunc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
338 |
28158
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
339 " test for using try/catch |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
340 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
341 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
342 let Trace = '1' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
343 try |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
344 let a1 = b1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
345 catch |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
346 let Trace ..= '2' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
347 finally |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
348 let Trace ..= '3' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
349 endtry |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
350 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
351 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
352 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
353 call assert_equal("123", g:Trace) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
354 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
355 " test with the finish command |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
356 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
357 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
358 let g:Color = 'blue' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
359 finish |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
360 let g:Color = 'green' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
361 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
362 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
363 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
364 call assert_equal('blue', g:Color) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
365 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
366 " Test for the SourcePre and SourcePost autocmds |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
367 augroup Xtest |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
368 au! |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
369 au SourcePre * let g:XsourcePre=4 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
370 \ | let g:XsourcePreFile = expand("<afile>") |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
371 au SourcePost * let g:XsourcePost=6 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
372 \ | let g:XsourcePostFile = expand("<afile>") |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
373 augroup END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
374 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
375 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
376 let a = 1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
377 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
378 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
379 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
380 call assert_equal(4, g:XsourcePre) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
381 call assert_equal(6, g:XsourcePost) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
382 call assert_equal(':source buffer=' .. bufnr(), g:XsourcePreFile) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
383 call assert_equal(':source buffer=' .. bufnr(), g:XsourcePostFile) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
384 augroup Xtest |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
385 au! |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
386 augroup END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
387 augroup! Xtest |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
388 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
389 %bw! |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
390 endfunc |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
391 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
392 " Test for sourcing a Vim9 script from the current buffer |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
393 func Test_source_buffer_vim9() |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
394 new |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
395 |
28139
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
396 " test for sourcing a Vim9 script |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
397 %d _ |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
398 let lines =<< trim END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
399 vim9script |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
400 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
401 # check dict |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
402 var x: number = 10 |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
403 def g:Xtestfunc(): number |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
404 return x |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
405 enddef |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
406 END |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
407 call setline(1, lines) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
408 source |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
409 call assert_equal(10, Xtestfunc()) |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
410 |
28158
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
411 " test for sourcing a vim9 script with line continuation |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
412 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
413 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
414 vim9script |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
415 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
416 g:Str1 = "hello " |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
417 .. "world" |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
418 .. ", how are you?" |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
419 g:Colors = [ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
420 'red', |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
421 # comment |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
422 'blue' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
423 ] |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
424 g:Dict = { |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
425 a: 22, |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
426 # comment |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
427 b: 33 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
428 } |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
429 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
430 # calling a function with line continuation |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
431 def Sum(...values: list<number>): number |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
432 var sum: number = 0 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
433 for v in values |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
434 sum += v |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
435 endfor |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
436 return sum |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
437 enddef |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
438 g:Total1 = Sum(10, |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
439 20, |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
440 30) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
441 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
442 var i: number = 0 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
443 while i < 10 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
444 # while loop |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
445 i += |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
446 1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
447 endwhile |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
448 g:Count1 = i |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
449 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
450 # for loop |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
451 g:Count2 = 0 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
452 for j in range(10, 20) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
453 g:Count2 += |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
454 i |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
455 endfor |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
456 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
457 g:Total2 = 10 + |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
458 20 - |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
459 5 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
460 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
461 g:Result1 = g:Total2 > 1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
462 ? 'red' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
463 : 'blue' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
464 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
465 g:Str2 = 'x' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
466 ->repeat(10) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
467 ->trim() |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
468 ->strpart(4) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
469 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
470 g:Result2 = g:Dict |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
471 .a |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
472 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
473 augroup Test |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
474 au! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
28903
diff
changeset
|
475 au BufNewFile Xsubfile g:readFile = 1 |
28158
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
476 | g:readExtra = 2 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
477 augroup END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
478 g:readFile = 0 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
479 g:readExtra = 0 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
28903
diff
changeset
|
480 new Xsubfile |
28158
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
481 bwipe! |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
482 augroup Test |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
483 au! |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
484 augroup END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
485 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
486 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
487 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
488 call assert_equal("hello world, how are you?", g:Str1) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
489 call assert_equal(['red', 'blue'], g:Colors) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
490 call assert_equal(#{a: 22, b: 33}, g:Dict) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
491 call assert_equal(60, g:Total1) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
492 call assert_equal(10, g:Count1) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
493 call assert_equal(110, g:Count2) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
494 call assert_equal(25, g:Total2) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
495 call assert_equal('red', g:Result1) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
496 call assert_equal('xxxxxx', g:Str2) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
497 call assert_equal(22, g:Result2) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
498 call assert_equal(1, g:readFile) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
499 call assert_equal(2, g:readExtra) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
500 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
501 " test for sourcing the same buffer multiple times after changing a function |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
502 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
503 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
504 vim9script |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
505 def g:Xtestfunc(): string |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
506 return "one" |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
507 enddef |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
508 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
509 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
510 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
511 call assert_equal("one", Xtestfunc()) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
512 call setline(3, ' return "two"') |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
513 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
514 call assert_equal("two", Xtestfunc()) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
515 call setline(3, ' return "three"') |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
516 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
517 call assert_equal("three", Xtestfunc()) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
518 delfunc Xtestfunc |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
519 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
520 " Test for sourcing a range of lines. Make sure the script line number is |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
521 " correct. |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
522 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
523 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
524 Line 1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
525 Line 2 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
526 vim9script |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
527 def g:Xtestfunc(): string |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
528 return expand("<sflnum>") |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
529 enddef |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
530 Line 3 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
531 Line 4 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
532 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
533 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
534 3,6source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
535 call assert_equal('5', Xtestfunc()) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
536 delfunc Xtestfunc |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
537 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
538 " test for sourcing a heredoc |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
539 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
540 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
541 vim9script |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
542 var a = 1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
543 g:heredoc =<< trim DATA |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
544 red |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
545 green |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
546 blue |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
547 DATA |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
548 var b = 2 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
549 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
550 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
551 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
552 call assert_equal(['red', ' green', 'blue'], g:heredoc) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
553 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
554 " test for using the :vim9cmd modifier |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
555 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
556 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
557 first line |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
558 g:Math = { |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
559 pi: 3.12, |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
560 e: 2.71828 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
561 } |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
562 g:Editors = [ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
563 'vim', |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
564 # comment |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
565 'nano' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
566 ] |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
567 last line |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
568 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
569 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
570 vim9cmd :2,10source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
571 call assert_equal(#{pi: 3.12, e: 2.71828}, g:Math) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
572 call assert_equal(['vim', 'nano'], g:Editors) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
573 |
28215
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
574 " '<,'> range before the cmd modifier works |
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
575 unlet g:Math |
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
576 unlet g:Editors |
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
577 exe "normal 6GV4j:vim9cmd source\<CR>" |
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
578 call assert_equal(['vim', 'nano'], g:Editors) |
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
579 unlet g:Editors |
cb462f4c6b12
patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
28164
diff
changeset
|
580 |
28158
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
581 " test for using try/catch |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
582 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
583 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
584 vim9script |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
585 g:Trace = '1' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
586 try |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
587 a1 = b1 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
588 catch |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
589 g:Trace ..= '2' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
590 finally |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
591 g:Trace ..= '3' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
592 endtry |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
593 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
594 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
595 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
596 call assert_equal('123', g:Trace) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
597 |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
598 " test with the finish command |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
599 %d _ |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
600 let lines =<< trim END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
601 vim9script |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
602 g:Color = 'red' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
603 finish |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
604 g:Color = 'blue' |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
605 END |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
606 call setline(1, lines) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
607 source |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
608 call assert_equal('red', g:Color) |
e1d1fa6ba1ed
patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
28139
diff
changeset
|
609 |
28164
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
610 " test for ++clear argument to clear all the functions/variables |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
611 %d _ |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
612 let lines =<< trim END |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
613 g:ScriptVarFound = exists("color") |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
614 g:MyFuncFound = exists('*Myfunc') |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
615 if g:MyFuncFound |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
616 finish |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
617 endif |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
618 var color = 'blue' |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
619 def Myfunc() |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
620 enddef |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
621 END |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
622 call setline(1, lines) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
623 vim9cmd source |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
624 call assert_false(g:MyFuncFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
625 call assert_false(g:ScriptVarFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
626 vim9cmd source |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
627 call assert_true(g:MyFuncFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
628 call assert_true(g:ScriptVarFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
629 vim9cmd source ++clear |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
630 call assert_false(g:MyFuncFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
631 call assert_false(g:ScriptVarFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
632 vim9cmd source ++clear |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
633 call assert_false(g:MyFuncFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
634 call assert_false(g:ScriptVarFound) |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
635 call assert_fails('vim9cmd source ++clearx', 'E475:') |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
636 call assert_fails('vim9cmd source ++abcde', 'E484:') |
b0b712d48225
patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents:
28158
diff
changeset
|
637 |
28139
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
638 %bw! |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
639 endfunc |
f34afadbef47
patch 8.2.4594: need to write script to a file to be able to source them
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
640 |
28242
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
641 func Test_source_buffer_long_line() |
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
642 " This was reading past the end of the line. |
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
643 new |
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
644 norm300gr0 |
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
645 so |
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
646 bwipe! |
28903
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
647 |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
648 let lines =<< trim END |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
649 new |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
650 norm 10a0000000000ΓΈ00000000000 |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
651 norm i0000000000000000000 |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
652 silent! so |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
653 END |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
654 call writefile(lines, 'Xtest.vim', 'D') |
28903
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
655 source Xtest.vim |
6a7d94628b5a
patch 8.2.4974: ":so" command may read after end of buffer
Bram Moolenaar <Bram@vim.org>
parents:
28242
diff
changeset
|
656 bwipe! |
28242
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
657 endfunc |
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
658 |
30433
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
659 func Test_source_buffer_with_NUL_char() |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
660 " This was trying to use a line below the buffer. |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
661 let lines =<< trim END |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
662 if !exists('g:loaded') |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
663 let g:loaded = 1 |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
664 source |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
665 endif |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
666 END |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
667 " Can't have a NL in heredoc |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
668 let lines += ["silent! vim9 echo [0 \<NL> ? 'a' : 'b']"] |
30556
b2a891f70f81
patch 9.0.0613: running source tests leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
30433
diff
changeset
|
669 call writefile(lines, 'XsourceNul', 'D') |
30433
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
670 edit XsourceNul |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
671 source |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
672 |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
673 bwipe! |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
674 endfunc |
36f1b763ae16
patch 9.0.0552: crash when using NUL in buffer that uses :source
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
675 |
28242
5bf82b918cb2
patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents:
28215
diff
changeset
|
676 |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19153
diff
changeset
|
677 " vim: shiftwidth=2 sts=2 expandtab |