Monday, February 5, 2018

Re: Writing tests for completion

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.

>
> Thanks,
> 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.

--
--
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:

Post a Comment