annotate src/testdir/test_true_false.vim @ 18478:94223687df0e

Added tag v8.1.2233 for changeset e93cab5d0f0f27fad7882f1f412927df055b090d
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Oct 2019 04:30:05 +0100
parents af3d441845cd
children 2a017e9dc6da
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
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " 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
4 func Test_if()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 if v:false
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 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
7 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 if 0
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_true(false, 'zero is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 if "0"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 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
13 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 if "foo"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_true(false, 'foo is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 if " "
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_true(false, 'space is false')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 if empty("foo")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 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
22 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 if v:true
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 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
27 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 if 1
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_true(false, 'one is true')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 if "1"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 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
35 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 if "1foo"
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 else
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 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
39 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call assert_fails('if [1]', 'E745')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 call assert_fails('if {1: 1}', 'E728')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_fails('if function("string")', 'E703')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_fails('if 1.3")', 'E805')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 function Try_arg_true_false(expr, false_val, true_val)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 for v in ['v:false', '0', '"0"', '"foo"', '" "']
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 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
50 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
51 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 for v in ['v:true', '1', '"1"', '"1foo"']
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 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
54 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
55 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 " 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
59 func Test_true_false_arg()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 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
61
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 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
64 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
65
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call setreg('a', ['x', 'y'])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 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
68
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 set wildignore=*.vim
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 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
71 set wildignore=*.swp
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", 0, %v%)', "runtest.vim", ["runtest.vim"])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 if has('unix')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 silent !ln -s doesntexit Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 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
76 silent !rm Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 set wildignore=*.vim
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 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
81 set wildignore=*.swp
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", 0, %v%)', "./runtest.vim", ["./runtest.vim"])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 if has('unix')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 silent !ln -s doesntexit Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 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
86 silent !rm Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 endif
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
88
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
89 abbr asdf asdff
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
90 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
91
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
92 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
93
9426
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
94 function FilterMapArg(d)
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
95 if type(a:d) == type({})
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
96 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
97 endif
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
98 return a:d
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
99 endfunction
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
100 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
101 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
102
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 9426
diff changeset
103 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
104
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
105 new colored
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
106 call setline(1, '<here>')
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
107 syn match brackets "<.*>"
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
108 syn match here "here" transparent
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
109 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
110 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
111 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
112 bwipe!
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 function Try_arg_non_zero(expr, false_val, true_val)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 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
118 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
119 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 for v in ['v:true', '1', '" "', '"0"']
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 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
122 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
123 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 " 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
128 func Test_non_zero_arg()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 call test_settime(93784)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 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
131 call test_settime(0)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 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
134
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 " visualmode() needs to be called twice to check
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 for v in [v:false, 0, [1], {2:3}, 3.4]
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 normal vv
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 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
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 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 for v in [v:true, 1, " ", "0"]
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 normal vv
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 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
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('', 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
149 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 endfunc