Christian Brabandt wrote:
> On So, 29 Nov 2015, Bram Moolenaar wrote:
>
> >
> > Testing Vim functionality has always been difficult. The tests in
> > src/testdir are hard to write and even harder to read back.
> >
> > I have just sent out patch 7.4.944 which should make testing easier.
> > This is what simple test looks like:
> >
> > func Test_assertFalse()
> > call assertFalse(0)
> > endfunc
> >
> > func Test_assertTrue()
> > call assertTrue(1)
> > call assertTrue(123)
> > endfunc
> >
> > func Test_assertEqual()
> > let s = 'foo'
> > call assertEqual('foo', s)
> > let n = 4
> > call assertEqual(4, n)
> > let l = [1, 2, 3]
> > call assertEqual([1, 2, 3], l)
> > endfunc
> >
> > The asserts are done where the value is available. No need to dig
> > through an .ok file or diff the .ok file with an .out file and then
> > guess where in the test something went wrong.
> >
> > The test script finds all the Test_ functions and executes them,
> > collecting any error messages from the asserts.
> >
> > An important limitation is that this only works with the +eval feature.
> > Testing a small or tiny Vim build still requires the old kind of
> > testing.
> >
> > What do you think?
> >
> > Obviously we can add more assert functions and improve their error
> > messages.
>
> I appreciate it to make testing easier. Writing and debugging the old
> tests are a huge PITA (sorry).
>
> However, as of now, I don't know how this is supposed to be better. Most
> of the tests I have written in the last time, were trying to test some
> visual feature, so I don't know how the assert functions are going to
> help with this.
>
> I have to see how this works out, before I can make a final assessment.
You will still have to manipulate text and yank or have some other way
to grab the result. But instead of putting the resulting text at the end
of the buffer, and later writing it to test.out, you can use
assertEqual() or assert_equal(). Thus there is no .ok file to update
and when a test fails you can see where it happens, intead of looking at
the diff and guessing where the change came from.
Another hint: put :finish before example text that you want to mess
with.
func Test_that()
...
endfunc
finish
Here: test some stuff on this text.
--
hundred-and-one symptoms of being an internet addict:
161. You get up before the sun rises to check your e-mail, and you
find yourself in the very same chair long after the sun has set.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.