blob: 534f05fd5333a6913a01eb0c7b20f16b8e882d90 [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
6The numbered tests are older, we have switched to named tests.
Bram Moolenaara9537d22014-08-29 10:04:47 +02007
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02008And then you can choose between a new style test, which is a Vim script, or an
Bram Moolenaar6602af72016-01-07 22:01:01 +01009old style test, which uses Normal mode commands. Use a new style test if you
10can.
11
12
13TO ADD A NEW STYLE TEST:
14
151) Create a test_<subject>.vim file.
162) Add test_<subject>.vim to NEW_TESTS in Make_all.mak in alphabetical order.
173) Use make test_<subject>.res to run a single test in src/testdir/.
18 Use make test_<subject> to run a single test in src/.
Bram Moolenaara9537d22014-08-29 10:04:47 +0200194) Also add an entry in src/Makefile.
20
Bram Moolenaar6602af72016-01-07 22:01:01 +010021What you can use (see test_assert.vim for an example):
22- Call assert_equal(), assert_true() and assert_false().
23- Use try/catch to check for exceptions.
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +020024- Use alloc_fail() to have memory allocation fail. This makes it possible
Bram Moolenaar6602af72016-01-07 22:01:01 +010025 to check memory allocation failures are handled gracefully. You need to
26 change the source code to add an ID to the allocation. Update LAST_ID_USED
27 above alloc_id() to the highest ID used.
Bram Moolenaar2ab375e2016-02-10 22:23:06 +010028- Use disable_char_avail_for_testing(1) if char_avail() must return FALSE for
29 a while. E.g. to trigger the CursorMovedI autocommand event.
30 See test_cursor_func.vim for an example
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +020031- See the start of runtest.vim for more help.
Bram Moolenaar6602af72016-01-07 22:01:01 +010032
33
34TO ADD AN OLD STYLE TEST:
35
361) Create test_<subject>.in and test_<subject>.ok files.
372) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order.
383) Use make test_<subject>.out to run a single test in src/testdir/.
39 Use make test_<subject> to run a single test in src/.
404) Also add an entry in src/Makefile.
41
42Keep in mind that the files are used as if everything was typed:
43- To add comments use: :" (that's an Ex command comment)
44- A line break is like pressing Enter. If that happens on the last line
45 you'll hear a beep!