On Wed, 22 Sep 2010, ZyX wrote:
Ответ на сообщение «Re: [BUG] getchar inside normal always returns an escape»,
присланное в 23:09:18 22 сентября 2010, Среда,
отправитель Bram Moolenaar:
I'm not sure this is supposed to work. ":normal" feeds characters
into Vim, using getchar() is problematic there.
According to the `:help :normal' ``{commands} is executed like it is typed.''
(here is probably a typo: should be ``{commands} are executed like if they were
typed'').
The syntax is okay. '{commands}' is being treated as a mass noun.
Something like "The string represented in the summary as {commands}".
If this does not work with `getchar()' then it should be mentioned in
documentation.
(no real input -- just commenting that I agree it's an omission.)
The script you give can also be sourced interactively.
What do you mean? I have a List with Lists with two items: user input
and my script output. I want to do something like this:
for [input, output] in tests
execute 'normal '.input
let result=getline(1, line('$'))
if result!=#output
throw "test failed"
endif
endfor
then tests can be done with `so %' just after they are written and
without opening another vim. Without normal command I will have to
write some annoying IPC stuff, the most simple suggestion is to write
result into file and check its content. If I continue finding such
bugs, I will have to write a framework for functional test of vim
plugins using something like pexpect, but now it is simpler to omit
those tests that cannot be easily written in Vimscript.
See the thread asking for a testing coördinator ("Looking for test
coordinator" from Bram starting on July 28)
http://groups.google.com/group/vim_dev/browse_thread/thread/e5245b45d87a74f0
Wasn't really resolved. But the point is that, no, there's no nice way
to test interactive things at the moment.
In this particular case, can't you script it by redirecting the messages
(via :h :redir) and writing them out to a file, and/or capturing
stdout/stderr?
Wrapping your file with:
redir > TESTmessages
" contents of test-normalesc.vim
redir END
the following seems to do what you want:
find ./ -maxdepth 1 -name 'TEST*' -delete
vi -u NONE -N +'so test-normalesc.vim' +'qa!' > TESTstdout 2> TESTstderr
head -n -0 TEST*
==> TESTmessages <==
27
27
27
27
27
27
27
27
27
27
10
==> TESTstderr <==
Vim: Warning: Output is not to a terminal
==> TESTstdout <==
--
Best,
Ben
Текст сообщения:
ZyX wrote:
In the attached script vim prints sequence of ten `27' (that is
character number of escape) and a `10', while it is supposed to print
99
104
97
114
115
5
(this is ASCII values of characters in string `chars' and a number of
symbols).
Test command:
vim -u NONE -c 'so test-normalesc.vim' -c 'messages' -c 'qa!'
I'm not sure this is supposed to work. ":normal" feeds characters into
Vim, using getchar() is problematic there.
PS: It looks like it is impossible to write tests for vim plugins
using vimscript, so I will now have to switch to something like
pexpect or just stop writing them.
The script you give can also be sourced interactively.
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php