annotate src/testdir/test_source.vim @ 28242:5bf82b918cb2 v8.2.4647

patch 8.2.4647: "source" can read past end of copied line Commit: https://github.com/vim/vim/commit/2bdad6126778f907c0b98002bfebf0e611a3f5db Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 29 19:52:12 2022 +0100 patch 8.2.4647: "source" can read past end of copied line Problem: "source" can read past end of copied line. Solution: Add a terminating NUL.
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Mar 2022 21:00:04 +0200
parents cb462f4c6b12
children 6a7d94628b5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15442
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for the :source command.
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
3 source check.vim
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
4 source view_util.vim
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
5
15442
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 func Test_source_autocmd()
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 call writefile([
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 \ 'let did_source = 1',
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 \ ], 'Xsourced')
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 au SourcePre *source* let did_source_pre = 1
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 au SourcePost *source* let did_source_post = 1
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 source Xsourced
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 call assert_equal(g:did_source, 1)
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 call assert_equal(g:did_source_pre, 1)
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 call assert_equal(g:did_source_post, 1)
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 call delete('Xsourced')
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 au! SourcePre
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 au! SourcePost
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 unlet g:did_source
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 unlet g:did_source_pre
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 unlet g:did_source_post
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 endfunc
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 func Test_source_cmd()
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 au SourceCmd *source* let did_source = expand('<afile>')
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 au SourcePre *source* let did_source_pre = 2
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 au SourcePost *source* let did_source_post = 2
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 source Xsourced
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call assert_equal(g:did_source, 'Xsourced')
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call assert_false(exists('g:did_source_pre'))
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call assert_equal(g:did_source_post, 2)
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 au! SourceCmd
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 au! SourcePre
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 au! SourcePost
3e2e1608efa4 patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 endfunc
16726
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
42
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
43 func Test_source_sandbox()
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
44 new
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
45 call writefile(["Ohello\<Esc>"], 'Xsourcehello')
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
46 source! Xsourcehello | echo
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
47 call assert_equal('hello', getline(1))
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
48 call assert_fails('sandbox source! Xsourcehello', 'E48:')
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
49 bwipe!
16920
8d91579414b8 patch 8.1.1461: tests do not run or are not reliable on some systems
Bram Moolenaar <Bram@vim.org>
parents: 16726
diff changeset
50 call delete('Xsourcehello')
16726
fbab59a5ee6b patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents: 15442
diff changeset
51 endfunc
19145
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
52
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
53 " When deleting a file and immediately creating a new one the inode may be
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
54 " recycled. Vim should not recognize it as the same script.
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
55 func Test_different_script()
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
56 call writefile(['let s:var = "asdf"'], 'XoneScript')
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
57 source XoneScript
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
58 call delete('XoneScript')
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
59 call writefile(['let g:var = s:var'], 'XtwoScript')
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
60 call assert_fails('source XtwoScript', 'E121:')
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
61 call delete('XtwoScript')
ea3ac1de7704 patch 8.2.0132: script may be re-used when deleting and creating a new one
Bram Moolenaar <Bram@vim.org>
parents: 16920
diff changeset
62 endfunc
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
63
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
64 " When sourcing a vim script, shebang should be ignored.
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
65 func Test_source_ignore_shebang()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
66 call writefile(['#!./xyzabc', 'let g:val=369'], 'Xfile.vim')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
67 source Xfile.vim
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
68 call assert_equal(g:val, 369)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
69 call delete('Xfile.vim')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
70 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
71
26771
fc859aea8cec patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
72 " 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
73 func Test_source_autocmd_sfile()
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
74 let code =<< trim [CODE]
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
75 let g:SfileName = ''
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
76 augroup sfiletest
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
77 au!
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
78 autocmd User UserAutoCmd let g:Sfile = '<sfile>:t'
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
79 augroup END
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
80 doautocmd User UserAutoCmd
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
81 let g:Slnum = expand('<slnum>')
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
82 let g:Sflnum = expand('<sflnum>')
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
83 augroup! sfiletest
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
84 [CODE]
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
85 call writefile(code, 'Xscript.vim')
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
86 source Xscript.vim
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
87 call assert_equal('Xscript.vim', g:Sfile)
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
88 call assert_equal('7', g:Slnum)
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
89 call assert_equal('8', g:Sflnum)
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
90 call delete('Xscript.vim')
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
91 endfunc
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
92
19950
9cbe3a4f1492 patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
93 func Test_source_error()
9cbe3a4f1492 patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
94 call assert_fails('scriptencoding utf-8', 'E167:')
9cbe3a4f1492 patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
95 call assert_fails('finish', 'E168:')
9cbe3a4f1492 patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
96 call assert_fails('scriptversion 2', 'E984:')
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
97 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
98 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
99 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
100 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
101 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
102 bw!
19950
9cbe3a4f1492 patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
103 endfunc
9cbe3a4f1492 patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
104
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
105 " 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
106 func Test_nested_script()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
107 CheckRunVimInTerminal
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
108 call writefile([':source! Xscript.vim', ''], 'Xscript.vim')
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
109 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
110 call term_wait(buf)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
111 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
112 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
113 call term_wait(buf)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
114 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
115 call delete('Xscript.vim')
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
116 call StopVimInTerminal(buf)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
117 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
118
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
119 " 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
120 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
121 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
122 " 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
123 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
124 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
125 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
126
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 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
128 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 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
130 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
131 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
132
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 " 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
134 %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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 .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
143 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
144 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
145 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
146 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
147 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
148
28158
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
149 " 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
150 " lines.
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
151 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
152 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
153 Line 1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
154 Line 2
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
155 func Xtestfunc()
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
156 return expand("<sflnum>")
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
157 endfunc
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
158 Line 3
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
159 Line 4
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
160 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
161 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
162 3,5source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
163 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
164 delfunc Xtestfunc
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
165
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
166 " 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
167 %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
168 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
169 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
170 \ 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
171 \ 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
172 \ ]
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 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
174 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
175 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
176 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
177 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
178 " 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
179 %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
180 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
181 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
182 "\ 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
183 \ '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
184 "\ 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
185 \ '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
186 \ ]
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 " 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
188 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
189 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
190 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
191 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
192 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
193 " 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
194 %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
195 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
196 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
197 \
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 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
199 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
200 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
201 " 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
202 %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
203 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
204 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
205 " 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 " 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
217 %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
218 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
219
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 " 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237
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 " 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
239 " 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
240 %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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256
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 " 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
258 %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
259 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
260 " 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
261 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
262 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
263 \ 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
264 "\ 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
265 \ 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
266 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
267 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 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
269 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
270 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
271 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
272
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 " 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
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 call writefile(lines, '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
289 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
290 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
291 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
292 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
293 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
294 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
295 call delete('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
296
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 " 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
298 %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
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 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
307 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
308 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
309 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
310 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
311
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 " 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
313 %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
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328
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 " 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
330 %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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346
28158
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
347 " 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
348 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
349 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
350 let Trace = '1'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
351 try
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
352 let a1 = b1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
353 catch
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
354 let Trace ..= '2'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
355 finally
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
356 let Trace ..= '3'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
357 endtry
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
358 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
359 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
360 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
361 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
362
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
363 " 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
364 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
365 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
366 let g:Color = 'blue'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
367 finish
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
368 let g:Color = 'green'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
369 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
370 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
371 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
372 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
373
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
374 " 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
375 augroup Xtest
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
376 au!
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
377 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
378 \ | 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
379 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
380 \ | 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
381 augroup END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
382 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
383 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
384 let a = 1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
385 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
386 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
387 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
388 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
389 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
390 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
391 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
392 augroup Xtest
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
393 au!
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
394 augroup END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
395 augroup! Xtest
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
396
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
397 %bw!
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
398 endfunc
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
399
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
400 " 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
401 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
402 new
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
403
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
404 " 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
405 %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
406 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
407 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
408
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 # 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
410 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
411 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
412 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
413 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
414 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
415 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
416 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
417 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
418
28158
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
419 " 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
420 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
421 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
422 vim9script
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:Str1 = "hello "
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
425 .. "world"
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
426 .. ", how are you?"
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
427 g:Colors = [
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
428 'red',
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
429 # comment
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
430 'blue'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
431 ]
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
432 g:Dict = {
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
433 a: 22,
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
434 # comment
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
435 b: 33
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
436 }
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
437
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
438 # 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
439 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
440 var sum: number = 0
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
441 for v in values
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
442 sum += v
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
443 endfor
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
444 return sum
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
445 enddef
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
446 g:Total1 = Sum(10,
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
447 20,
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
448 30)
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 var i: number = 0
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
451 while i < 10
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
452 # while loop
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
453 i +=
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
454 1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
455 endwhile
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
456 g:Count1 = i
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
457
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
458 # for loop
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
459 g:Count2 = 0
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
460 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
461 g:Count2 +=
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
462 i
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
463 endfor
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:Total2 = 10 +
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
466 20 -
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
467 5
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
468
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
469 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
470 ? 'red'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
471 : 'blue'
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 g:Str2 = 'x'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
474 ->repeat(10)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
475 ->trim()
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
476 ->strpart(4)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
477
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
478 g:Result2 = g:Dict
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
479 .a
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
480
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
481 augroup Test
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
482 au!
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
483 au BufNewFile Xfile g:readFile = 1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
484 | g:readExtra = 2
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
485 augroup END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
486 g:readFile = 0
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
487 g:readExtra = 0
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
488 new Xfile
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
489 bwipe!
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
490 augroup Test
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
491 au!
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
492 augroup END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
493 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
494 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
495 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
496 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
497 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
498 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
499 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
500 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
501 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
502 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
503 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
504 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
505 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
506 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
507 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
508
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
509 " 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
510 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
511 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
512 vim9script
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
513 def g:Xtestfunc(): string
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
514 return "one"
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
515 enddef
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
516 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
517 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
518 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
519 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
520 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
521 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
522 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
523 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
524 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
525 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
526 delfunc Xtestfunc
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
527
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
528 " 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
529 " correct.
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
530 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
531 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
532 Line 1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
533 Line 2
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
534 vim9script
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
535 def g:Xtestfunc(): string
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
536 return expand("<sflnum>")
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
537 enddef
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
538 Line 3
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
539 Line 4
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
540 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
541 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
542 3,6source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
543 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
544 delfunc Xtestfunc
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
545
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
546 " 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
547 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
548 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
549 vim9script
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
550 var a = 1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
551 g:heredoc =<< trim DATA
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
552 red
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
553 green
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
554 blue
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
555 DATA
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
556 var b = 2
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
557 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
558 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
559 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
560 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
561
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
562 " 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
563 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
564 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
565 first line
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
566 g:Math = {
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
567 pi: 3.12,
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
568 e: 2.71828
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
569 }
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
570 g:Editors = [
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
571 'vim',
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
572 # comment
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
573 'nano'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
574 ]
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
575 last line
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
576 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
577 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
578 vim9cmd :2,10source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
579 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
580 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
581
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28164
diff changeset
582 " '<,'> 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
583 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
584 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
585 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
586 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
587 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
588
28158
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
589 " 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
590 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
591 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
592 vim9script
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
593 g:Trace = '1'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
594 try
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
595 a1 = b1
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
596 catch
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
597 g:Trace ..= '2'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
598 finally
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
599 g:Trace ..= '3'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
600 endtry
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
601 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
602 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
603 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
604 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
605
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
606 " 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
607 %d _
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
608 let lines =<< trim END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
609 vim9script
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
610 g:Color = 'red'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
611 finish
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
612 g:Color = 'blue'
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
613 END
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
614 call setline(1, lines)
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
615 source
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28139
diff changeset
616 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
617
28164
b0b712d48225 patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
618 " 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
619 %d _
b0b712d48225 patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
620 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
621 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
622 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
623 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
624 finish
b0b712d48225 patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
625 endif
b0b712d48225 patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
626 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
627 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
628 enddef
b0b712d48225 patch 8.2.4607: sourcing buffer lines may lead to errors for conflicts
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
629 END
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 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
631 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
632 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
633 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
634 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
635 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
636 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
637 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
638 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
639 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
640 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
641 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
642 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
643 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
644 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
645
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
646 %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
647 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
648
28242
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
649 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
650 " 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
651 new
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
652 norm300gr0
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
653 so
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
654 bwipe!
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
655 endfunc
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
656
5bf82b918cb2 patch 8.2.4647: "source" can read past end of copied line
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
657
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19153
diff changeset
658 " vim: shiftwidth=2 sts=2 expandtab