annotate src/testdir/test_true_false.vim @ 24333:47d55d8a93c9 v8.2.2707

patch 8.2.2707: adding a lot of completions can still be a bit slow Commit: https://github.com/vim/vim/commit/ceb06194337f1a9d30cd12edb7b0dc51830b9cb7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 4 15:05:22 2021 +0200 patch 8.2.2707: adding a lot of completions can still be a bit slow Problem: Adding a lot of completions can still be a bit slow. Solution: Add the check for CP_FAST. (Ben Jackson)
author Bram Moolenaar <Bram@vim.org>
date Sun, 04 Apr 2021 15:15:04 +0200
parents ff21e2962490
children 029c59bf78f1
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:')
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
46 if has('float')
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
47 call assert_fails('if 1.3")', 'E805:')
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
48 endif
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 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
52 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
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: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
55 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 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
57 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
58 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
59 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 endfunc
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 " 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
63 func Test_true_false_arg()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 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
65
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 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
68 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
69
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call setreg('a', ['x', 'y'])
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 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
72
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 set wildignore=*.vim
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", %v%)', "", "runtest.vim")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 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
77 if has('unix')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 silent !ln -s doesntexit Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 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
80 silent !rm Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endif
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 set wildignore=*.vim
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", %v%)', "", "./runtest.vim")
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 set wildignore=*.swp
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 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
87 if has('unix')
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 silent !ln -s doesntexit Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 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
90 silent !rm Xlink
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 endif
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
92
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
93 abbr asdf asdff
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
94 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
95
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
96 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
97
9426
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
98 function FilterMapArg(d)
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
99 if type(a:d) == type({})
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
100 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
101 endif
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
102 return a:d
d606560082e6 commit https://github.com/vim/vim/commit/05e418d436410cd8bbf5a29ff81e8ad68408b1e8
Christian Brabandt <cb@256bit.org>
parents: 9424
diff changeset
103 endfunction
9424
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
104 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
105 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
106
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 9426
diff changeset
107 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
108
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
109 new colored
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
110 call setline(1, '<here>')
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
111 syn match brackets "<.*>"
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
112 syn match here "here" transparent
fd4e6d944f4a commit https://github.com/vim/vim/commit/6bb450145e96d7b182769fd9502a267da72667ec
Christian Brabandt <cb@256bit.org>
parents: 9422
diff changeset
113 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
114 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
115 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
116 bwipe!
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 function Try_arg_non_zero(expr, false_val, true_val)
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
120 CheckFeature float
9422
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 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
122 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
123 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
124 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 for v in ['v:true', '1', '" "', '"0"']
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 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
127 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
128 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 endfunc
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 " 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
133 func Test_non_zero_arg()
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 call test_settime(93784)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 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
136 call test_settime(0)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 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
139
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 " 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
141 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
142 normal vv
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 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
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 ' . string(v) . ' is not "v" but ' . r)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 for v in [v:true, 1, " ", "0"]
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 normal vv
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 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
152 let r = visualmode(v)
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 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
154 endfor
f93704b11e43 commit https://github.com/vim/vim/commit/e381d3d5e098546854b008e01ca1d28ba1a4a057
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
156
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
157 " vim: shiftwidth=2 sts=2 expandtab