annotate src/testdir/test_true_false.vim @ 35172:c98f002b1fe4 default tip

runtime(doc): fix typo in usr_52.txt Commit: https://github.com/vim/vim/commit/b7258738f80f26be302a84a99f968b3bdc2f29bb Author: Christian Brabandt <cb@256bit.org> Date: Sun May 12 19:04:47 2024 +0200 runtime(doc): fix typo in usr_52.txt fixes: https://github.com/vim/vim/issues/14758 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 12 May 2024 19:15:08 +0200
parents dbec60b8c253
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test behavior of boolean-like values.
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
3 source check.vim
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
4
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " Test what is explained at ":help TRUE" and ":help FALSE".
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 func Test_if()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 if v:false
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call assert_true(false, 'v:false is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 if 0
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call assert_true(false, 'zero is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 if "0"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_true(false, 'zero string is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 if "foo"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_true(false, 'foo is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 if " "
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_true(false, 'space is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 if empty("foo")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_true(false, 'foo is not empty')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 if v:true
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call assert_true(false, 'v:true is true')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 if 1
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_true(false, 'one is true')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 if "1"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_true(false, 'one string is true')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 if "1foo"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_true(false, 'one in string is true')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
43 call assert_fails('if [1]', 'E745:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
44 call assert_fails('if {1: 1}', 'E728:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
45 call assert_fails('if function("string")', 'E703:')
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
46 call assert_fails('if 1.3")', 'E805:')
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 function Try_arg_true_false(expr, false_val, true_val)
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
50 for v in ['v:false', '0', '"0"', '"foo"', '" "']
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 let r = eval(substitute(a:expr, '%v%', v, ''))
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . string(a:false_val) . ' but ' . string(r))
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 endfor
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
54 for v in ['v:true', '1', '"1"', '"1foo"']
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 let r = eval(substitute(a:expr, '%v%', v, ''))
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call assert_equal(a:true_val, r, 'result for ' . v . ' is not ' . string(a:true_val) . ' but ' . string(r))
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 " Test using TRUE or FALSE values for an argument.
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 func Test_true_false_arg()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call Try_arg_true_false('count(["a", "A"], "a", %v%)', 1, 2)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call Try_arg_true_false('expand("foo.swp", %v%)', "", "foo.swp")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call Try_arg_true_false('expand("foo.vim", 0, %v%)', "foo.vim", ["foo.vim"])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call setreg('a', ['x', 'y'])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call Try_arg_true_false('getreg("a", 1, %v%)', "x\ny\n", ['x', 'y'])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 set wildignore=*.vim
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call Try_arg_true_false('glob("runtest.vim", %v%)', "", "runtest.vim")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call Try_arg_true_false('glob("runtest.vim", 0, %v%)', "runtest.vim", ["runtest.vim"])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 if has('unix')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 silent !ln -s doesntexit Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call Try_arg_true_false('glob("Xlink", 0, 0, %v%)', "", "Xlink")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 silent !rm Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 set wildignore=*.vim
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 call Try_arg_true_false('globpath(".", "runtest.vim", %v%)', "", "./runtest.vim")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 call Try_arg_true_false('globpath(".", "runtest.vim", 0, %v%)', "./runtest.vim", ["./runtest.vim"])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 if has('unix')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 silent !ln -s doesntexit Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 call Try_arg_true_false('globpath(".", "Xlink", 0, 0, %v%)', "", "./Xlink")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 silent !rm Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 endif
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
90
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
91 abbr asdf asdff
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
92 call Try_arg_true_false('hasmapto("asdff", "i", %v%)', 0, 1)
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
93
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
94 call Try_arg_true_false('index(["a", "A"], "A", 0, %v%)', 1, 0)
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
95
9426
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
96 function FilterMapArg(d)
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
97 if type(a:d) == type({})
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
98 return filter(a:d, 'v:key == "rhs"')
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
99 endif
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
100 return a:d
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
101 endfunction
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
102 call Try_arg_true_false('maparg("asdf", "i", %v%)', "", "asdff")
9426
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
103 call Try_arg_true_false('FilterMapArg(maparg("asdf", "i", 1, %v%))', "asdff", {'rhs': 'asdff'})
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
104
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 9426
diff changeset
105 call Try_arg_true_false('"asdf"->hasmapto("i", %v%)', 0, 1)
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
106
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
107 new colored
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
108 call setline(1, '<here>')
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
109 syn match brackets "<.*>"
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
110 syn match here "here" transparent
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
111 let brackets_id = synID(1, 1, 0)
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
112 let here_id = synID(1, 3, 0)
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
113 call Try_arg_true_false('synID(1, 3, %v%)', here_id, brackets_id)
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
114 bwipe!
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 function Try_arg_non_zero(expr, false_val, true_val)
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
118 for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 let r = eval(substitute(a:expr, '%v%', v, ''))
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 endfor
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
122 for v in ['v:true', '1', '" "', '"0"']
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 let r = eval(substitute(a:expr, '%v%', v, ''))
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 call assert_equal(a:true_val, r, 'result for ' . v . ' is not ' . a:true_val . ' but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 " Test using non-zero-arg for an argument.
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 func Test_non_zero_arg()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 call test_settime(93784)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 call Try_arg_non_zero("mode(%v%)", 'x', 'x!')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 call test_settime(0)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 call Try_arg_non_zero("shellescape('foo%', %v%)", "'foo%'", "'foo\\%'")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 " visualmode() needs to be called twice to check
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
138 for v in [v:false, 0, [1], {2:3}, 3.4]
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 normal vv
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 call assert_equal('v', r, 'result for ' . string(v) . ' is not "v" but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 call assert_equal('v', r, 'result for ' . string(v) . ' is not "v" but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 endfor
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
145 for v in [v:true, 1, " ", "0"]
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 normal vv
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 call assert_equal('v', r, 'result for ' . v . ' is not "v" but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 call assert_equal('', r, 'result for ' . v . ' is not "" but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
153
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
154 " vim: shiftwidth=2 sts=2 expandtab