Mercurial > vim
annotate src/testdir/test_source.vim @ 18785:b3ddaa7a8b5b
Added tag v8.1.2381 for changeset 7b57a80f70f6454e1e374678dd2e28f3f3aab888
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Dec 2019 20:45:04 +0100 |
parents | 8d91579414b8 |
children | ea3ac1de7704 |
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 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 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
|
4 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
|
5 \ '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
|
6 \ ], 'Xsourced') |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 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
|
8 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
|
9 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 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
|
11 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 |
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 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 endfunc |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 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
|
25 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
|
26 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
|
27 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
|
28 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 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
|
30 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 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
|
32 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
|
33 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
|
34 |
3e2e1608efa4
patch 8.1.0729: there is a SourcePre autocommand event but not a SourcePost
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 endfunc |
16726
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
39 |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
40 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
|
41 new |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
15442
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 endfunc |