Mercurial > vim
annotate src/testdir/test_unlet.vim @ 20622:d487701a608e
Added tag v8.2.0864 for changeset d30b16692ce0ef62ead483068caa67cb03c2b795
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 31 May 2020 18:00:04 +0200 |
parents | 0b35a7ffceb2 |
children |
rev | line source |
---|---|
7498
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for :unlet |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 func Test_read_only() |
7595
99e93f72ff91
commit https://github.com/vim/vim/commit/065ee9aebf9abe08ae8c0dba7d05cbdcc423c8e0
Christian Brabandt <cb@256bit.org>
parents:
7562
diff
changeset
|
4 " these caused a crash |
99e93f72ff91
commit https://github.com/vim/vim/commit/065ee9aebf9abe08ae8c0dba7d05cbdcc423c8e0
Christian Brabandt <cb@256bit.org>
parents:
7562
diff
changeset
|
5 call assert_fails('unlet count', 'E795:') |
99e93f72ff91
commit https://github.com/vim/vim/commit/065ee9aebf9abe08ae8c0dba7d05cbdcc423c8e0
Christian Brabandt <cb@256bit.org>
parents:
7562
diff
changeset
|
6 call assert_fails('unlet errmsg', 'E795:') |
7498
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 endfunc |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 func Test_existing() |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let does_exist = 1 |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 call assert_true(exists('does_exist')) |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 unlet does_exist |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call assert_false(exists('does_exist')) |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 endfunc |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 func Test_not_existing() |
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 unlet! does_not_exist |
7595
99e93f72ff91
commit https://github.com/vim/vim/commit/065ee9aebf9abe08ae8c0dba7d05cbdcc423c8e0
Christian Brabandt <cb@256bit.org>
parents:
7562
diff
changeset
|
18 call assert_fails('unlet does_not_exist', 'E108:') |
7498
3fcd3d235f7b
commit https://github.com/vim/vim/commit/af8af8bfac5792fa64efbc524032d568cc7754f7
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 endfunc |
10910
8bff367672a4
patch 8.0.0344: unlet command leaks memory
Christian Brabandt <cb@256bit.org>
parents:
7595
diff
changeset
|
20 |
8bff367672a4
patch 8.0.0344: unlet command leaks memory
Christian Brabandt <cb@256bit.org>
parents:
7595
diff
changeset
|
21 func Test_unlet_fails() |
8bff367672a4
patch 8.0.0344: unlet command leaks memory
Christian Brabandt <cb@256bit.org>
parents:
7595
diff
changeset
|
22 call assert_fails('unlet v:["count"]', 'E46:') |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
14059
diff
changeset
|
23 call assert_fails('unlet $', 'E475:') |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
24 let v = {} |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
25 call assert_fails('unlet v[:]', 'E719:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
26 let l = [] |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
27 call assert_fails("unlet l['k'", 'E111:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
28 let d = {'k' : 1} |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
29 call assert_fails("unlet d.k2", 'E716:') |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
30 call assert_fails("unlet {a};", 'E488:') |
10910
8bff367672a4
patch 8.0.0344: unlet command leaks memory
Christian Brabandt <cb@256bit.org>
parents:
7595
diff
changeset
|
31 endfunc |
13923
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
32 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
33 func Test_unlet_env() |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
34 let envcmd = has('win32') ? 'set' : 'env' |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
35 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
36 let $FOOBAR = 'test' |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
37 let found = 0 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
38 for kv in split(system(envcmd), "\r*\n") |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
39 if kv == 'FOOBAR=test' |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
40 let found = 1 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
41 endif |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
42 endfor |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
43 call assert_equal(1, found) |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
44 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
45 unlet $FOOBAR |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
46 let found = 0 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
47 for kv in split(system(envcmd), "\r*\n") |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
48 if kv == 'FOOBAR=test' |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
49 let found = 1 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
50 endif |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
51 endfor |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
52 call assert_equal(0, found) |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
53 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
54 unlet $MUST_NOT_BE_AN_ERROR |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
55 endfunc |
14059
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
56 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
57 func Test_unlet_complete() |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
58 let g:FOOBAR = 1 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
59 call feedkeys(":unlet g:FOO\t\n", 'tx') |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
60 call assert_true(!exists('g:FOOBAR')) |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
61 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
62 let $FOOBAR = 1 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
63 call feedkeys(":unlet $FOO\t\n", 'tx') |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
64 call assert_true(!exists('$FOOBAR') || empty($FOOBAR)) |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
65 endfunc |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
14059
diff
changeset
|
66 |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
14059
diff
changeset
|
67 " vim: shiftwidth=2 sts=2 expandtab |