blob: 3b2e101c8f8e57cc63608b45a6a83133c928180d [file] [log] [blame]
Bram Moolenaara9537d22014-08-29 10:04:47 +02001This directory contains tests for various Vim features.
2
Bram Moolenaar6602af72016-01-07 22:01:01 +01003If it makes sense, add a new test method to an already existing file. You may
4want to separate it from other tests with comment lines.
Bram Moolenaara9537d22014-08-29 10:04:47 +02005
Bram Moolenaar9e4d8212016-08-18 23:04:48 +02006The numbered tests are older, we have switched to named tests. Don't add any
7more numbered tests.
Bram Moolenaara9537d22014-08-29 10:04:47 +02008
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02009And then you can choose between a new style test, which is a Vim script, or an
Bram Moolenaar6602af72016-01-07 22:01:01 +010010old style test, which uses Normal mode commands. Use a new style test if you
Bram Moolenaar9e4d8212016-08-18 23:04:48 +020011can. Use an old style test when it needs to run without the +eval feature.
Bram Moolenaar6602af72016-01-07 22:01:01 +010012
13
14TO ADD A NEW STYLE TEST:
15
161) Create a test_<subject>.vim file.
172) Add test_<subject>.vim to NEW_TESTS in Make_all.mak in alphabetical order.
183) Use make test_<subject>.res to run a single test in src/testdir/.
19 Use make test_<subject> to run a single test in src/.
Bram Moolenaara9537d22014-08-29 10:04:47 +0200204) Also add an entry in src/Makefile.
21
Bram Moolenaar6602af72016-01-07 22:01:01 +010022What you can use (see test_assert.vim for an example):
23- Call assert_equal(), assert_true() and assert_false().
24- Use try/catch to check for exceptions.
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +020025- Use alloc_fail() to have memory allocation fail. This makes it possible
Bram Moolenaar6602af72016-01-07 22:01:01 +010026 to check memory allocation failures are handled gracefully. You need to
27 change the source code to add an ID to the allocation. Update LAST_ID_USED
28 above alloc_id() to the highest ID used.
Bram Moolenaar2ab375e2016-02-10 22:23:06 +010029- Use disable_char_avail_for_testing(1) if char_avail() must return FALSE for
30 a while. E.g. to trigger the CursorMovedI autocommand event.
31 See test_cursor_func.vim for an example
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +020032- See the start of runtest.vim for more help.
Bram Moolenaar6602af72016-01-07 22:01:01 +010033
34
35TO ADD AN OLD STYLE TEST:
36
371) Create test_<subject>.in and test_<subject>.ok files.
382) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order.
393) Use make test_<subject>.out to run a single test in src/testdir/.
40 Use make test_<subject> to run a single test in src/.
414) Also add an entry in src/Makefile.
42
43Keep in mind that the files are used as if everything was typed:
44- To add comments use: :" (that's an Ex command comment)
45- A line break is like pressing Enter. If that happens on the last line
46 you'll hear a beep!