Bram Moolenaar | a9537d2 | 2014-08-29 10:04:47 +0200 | [diff] [blame] | 1 | This directory contains tests for various Vim features. |
| 2 | |
Bram Moolenaar | 6602af7 | 2016-01-07 22:01:01 +0100 | [diff] [blame] | 3 | If it makes sense, add a new test method to an already existing file. You may |
| 4 | want to separate it from other tests with comment lines. |
Bram Moolenaar | a9537d2 | 2014-08-29 10:04:47 +0200 | [diff] [blame] | 5 | |
| 6 | The numbered tests are older, we have switched to named tests. |
Bram Moolenaar | a9537d2 | 2014-08-29 10:04:47 +0200 | [diff] [blame] | 7 | |
Bram Moolenaar | 6602af7 | 2016-01-07 22:01:01 +0100 | [diff] [blame] | 8 | And then you can chose between a new style test, which is a Vim script, or an |
| 9 | old style test, which uses Normal mode commands. Use a new style test if you |
| 10 | can. |
| 11 | |
| 12 | |
| 13 | TO ADD A NEW STYLE TEST: |
| 14 | |
| 15 | 1) Create a test_<subject>.vim file. |
| 16 | 2) Add test_<subject>.vim to NEW_TESTS in Make_all.mak in alphabetical order. |
| 17 | 3) 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 Moolenaar | a9537d2 | 2014-08-29 10:04:47 +0200 | [diff] [blame] | 19 | 4) Also add an entry in src/Makefile. |
| 20 | |
Bram Moolenaar | 6602af7 | 2016-01-07 22:01:01 +0100 | [diff] [blame] | 21 | What 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 Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 28 | - 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 Moolenaar | 6602af7 | 2016-01-07 22:01:01 +0100 | [diff] [blame] | 31 | |
| 32 | |
| 33 | TO ADD AN OLD STYLE TEST: |
| 34 | |
| 35 | 1) Create test_<subject>.in and test_<subject>.ok files. |
| 36 | 2) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order. |
| 37 | 3) 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/. |
| 39 | 4) Also add an entry in src/Makefile. |
| 40 | |
| 41 | Keep 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! |