Mercurial > vim
annotate src/testdir/test_unlet.vim @ 14191:ec39f281e3e8 v8.1.0113
patch 8.1.0113: compiler warning for unused variable
commit https://github.com/vim/vim/commit/829adb74605604ff0bec33862cde850efb294711
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 24 19:24:03 2018 +0200
patch 8.1.0113: compiler warning for unused variable
Problem: Compiler warning for unused variable. (Yegappan Lakshmanan)
Solution: Add UNUSED. (Christian Brabandt)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Jun 2018 19:30:05 +0200 |
parents | a94bc6a7b29e |
children | da98d2ed8dc5 |
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:') |
8bff367672a4
patch 8.0.0344: unlet command leaks memory
Christian Brabandt <cb@256bit.org>
parents:
7595
diff
changeset
|
23 endfunc |
13923
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
24 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
25 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
|
26 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
|
27 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
28 let $FOOBAR = 'test' |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
29 let found = 0 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
30 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
|
31 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
|
32 let found = 1 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
33 endif |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
34 endfor |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
35 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
|
36 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
37 unlet $FOOBAR |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
38 let found = 0 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
39 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
|
40 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
|
41 let found = 1 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
42 endif |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
43 endfor |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
44 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
|
45 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
10910
diff
changeset
|
46 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
|
47 endfunc |
14059
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
48 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
49 func Test_unlet_complete() |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
50 let g:FOOBAR = 1 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
51 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
|
52 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
|
53 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
54 let $FOOBAR = 1 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
55 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
|
56 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
|
57 endfunc |