Monday, February 5, 2018

Re: Writing tests for completion

On 05/02/2018 22:49, Nikolay Aleksandrovich Pavlov wrote:
> 2018-02-05 23:31 GMT+03:00 Lifepillar <lifepillar@lifepillar.me>:
>> I would like to automate the testing of my completion plugin,
>> so I have started to write functions like this (I am using
>> a test framework like the one in Vim):
>>
>> fun! Test_buffer_keyword_completion()
>> new
>> set completeopt=menuone,noselect
>> call feedkeys("ajump ju\<C-X>\<C-N>\<C-N>\<ESC>", "x")
>> call assert_equal("jump jump", getline(1))
>> bwipe!
>> endf
>>
>> This test passes (using `vim --clean`), but if I feed this
>> key sequence instead:
>>
>> call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "x")
>>
>> the test fails:
>>
>> Expected 'jump jump' but got 'jump ju'
>>
>> Why is that? If I try the key sequences manually, both give the
>> same result.
>
> To emulate user input you must add `t` to the flags, there are some
> differences between handling input from user and input from mappings
> and without `t` you are emulating the latter. I could not list all the
> differences though.

Adding "t" does not seem to make a difference in this case. This is a
simplified way to reproduce the difference:

vim --clean
:set completeopt=menuone,noselect
:call feedkeys("ajump ju\<C-X>\<C-N>\<C-N>\<ESC>", "tx")
:call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "tx")

As I said, manual typing does not show any difference (the result is
"jump jump" in both cases). Am I missing something?
I am using Vim 8.0.1450.

Life.

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: