patch 7.4.2008
Problem: evalcmd() has a confusing name.
Solution: Rename to execute(). Make silent optional. Support a list of
commands.
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
index 074c2de..3074a5c 100644
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -5,7 +5,7 @@
source test_autocmd.vim
source test_cursor_func.vim
source test_delete.vim
-source test_evalcmd.vim
+source test_execute_func.vim
source test_ex_undo.vim
source test_expand.vim
source test_expr.vim
diff --git a/src/testdir/test_evalcmd.vim b/src/testdir/test_evalcmd.vim
deleted file mode 100644
index a9bda87..0000000
--- a/src/testdir/test_evalcmd.vim
+++ /dev/null
@@ -1,33 +0,0 @@
-" test evalcmd()
-
-func NestedEval()
- let nested = evalcmd('echo "nested\nlines"')
- echo 'got: "' . nested . '"'
-endfunc
-
-func NestedRedir()
- redir => var
- echo 'broken'
- redir END
-endfunc
-
-func Test_evalcmd()
- call assert_equal("\nnocompatible", evalcmd('set compatible?'))
- call assert_equal("\nsomething\nnice", evalcmd('echo "something\nnice"'))
- call assert_equal("noendofline", evalcmd('echon "noendofline"'))
- call assert_equal("", evalcmd(123))
-
- call assert_equal("\ngot: \"\nnested\nlines\"", evalcmd('call NestedEval()'))
- redir => redired
- echo 'this'
- let evaled = evalcmd('echo "that"')
- echo 'theend'
- redir END
- call assert_equal("\nthis\ntheend", redired)
- call assert_equal("\nthat", evaled)
-
- call assert_fails('call evalcmd("doesnotexist")', 'E492:')
- call assert_fails('call evalcmd(3.4)', 'E806:')
- call assert_fails('call evalcmd("call NestedRedir()")', 'E930:')
-endfunc
-
diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim
new file mode 100644
index 0000000..dd07e4a
--- /dev/null
+++ b/src/testdir/test_execute_func.vim
@@ -0,0 +1,51 @@
+" test execute()
+
+func NestedEval()
+ let nested = execute('echo "nested\nlines"')
+ echo 'got: "' . nested . '"'
+endfunc
+
+func NestedRedir()
+ redir => var
+ echo 'broken'
+ redir END
+endfunc
+
+func Test_execute_string()
+ call assert_equal("\nnocompatible", execute('set compatible?'))
+ call assert_equal("\nsomething\nnice", execute('echo "something\nnice"'))
+ call assert_equal("noendofline", execute('echon "noendofline"'))
+ call assert_equal("", execute(123))
+
+ call assert_equal("\ngot: \"\nnested\nlines\"", execute('call NestedEval()'))
+ redir => redired
+ echo 'this'
+ let evaled = execute('echo "that"')
+ echo 'theend'
+ redir END
+ call assert_equal("\nthis\ntheend", redired)
+ call assert_equal("\nthat", evaled)
+
+ call assert_fails('call execute("doesnotexist")', 'E492:')
+ call assert_fails('call execute(3.4)', 'E806:')
+ call assert_fails('call execute("call NestedRedir()")', 'E930:')
+
+ call assert_equal("\nsomething", execute('echo "something"', ''))
+ call assert_equal("\nsomething", execute('echo "something"', 'silent'))
+ call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
+ call assert_equal("", execute('burp', 'silent!'))
+ call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:')
+
+ call assert_equal("", execute(test_null_string()))
+endfunc
+
+func Test_execute_list()
+ call assert_equal("\nsomething\nnice", execute(['echo "something"', 'echo "nice"']))
+ let l = ['for n in range(0, 3)',
+ \ 'echo n',
+ \ 'endfor']
+ call assert_equal("\n0\n1\n2\n3", execute(l))
+
+ call assert_equal("", execute([]))
+ call assert_equal("", execute(test_null_list()))
+endfunc