blob: 052ccf5a2a24c6b7bd192d41043b803c92f07f34 [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 Moolenaar6602af72016-01-07 22:01:01 +01008And then you can chose between a new style test, which is a Vim script, or an
9old 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.
24- Use alloc_fail() to have memory allocation fail. This makes it possible to
25 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 Moolenaar6602af72016-01-07 22:01:01 +010031
32
33TO ADD AN OLD STYLE TEST:
34
351) Create test_<subject>.in and test_<subject>.ok files.
362) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order.
373) Use make test_<subject>.out to run a single test in src/testdir/.
38 Use make test_<subject> to run a single test in src/.
394) Also add an entry in src/Makefile.
40
41Keep in mind that the files are used as if everything was typed:
42- To add comments use: :" (that's an Ex command comment)
43- A line break is like pressing Enter. If that happens on the last line
44 you'll hear a beep!