|
1 | 1 | This directory contains tests for various Vim features. |
2 | 2 |
|
3 | | -If it makes sense, try to add a new test to an already existing file. You may |
4 | | -want to separate it from other tests in that file using :" (that's an Ex |
5 | | -command comment). |
| 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. |
6 | 5 |
|
7 | 6 | The numbered tests are older, we have switched to named tests. |
8 | | -And the newest way of testing is to use assert functions, see test_assert.vim |
9 | | -for an example. |
10 | 7 |
|
11 | | -To add a new test: |
| 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/. |
| 19 | +4) Also add an entry in src/Makefile. |
| 20 | + |
| 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. |
| 28 | + |
| 29 | + |
| 30 | +TO ADD AN OLD STYLE TEST: |
| 31 | + |
12 | 32 | 1) Create test_<subject>.in and test_<subject>.ok files. |
13 | | -2) Add them to all Makefiles (Make*) in alphabetical order (search for an |
14 | | - existing test_file.out to see where to add the new one). |
15 | | -3) Use make test_<subject>.out to run a single test file in src/testdir/. |
| 33 | +2) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order. |
| 34 | +3) Use make test_<subject>.out to run a single test in src/testdir/. |
| 35 | + Use make test_<subject> to run a single test in src/. |
16 | 36 | 4) Also add an entry in src/Makefile. |
17 | 37 |
|
18 | | -Keep in mind that the files are used as if everything was typed. |
19 | | -A line break is like pressing Enter. If that happens on the last line you'll |
20 | | -hear a beep. |
| 38 | +Keep in mind that the files are used as if everything was typed: |
| 39 | +- To add comments use: :" (that's an Ex command comment) |
| 40 | +- A line break is like pressing Enter. If that happens on the last line |
| 41 | + you'll hear a beep! |
0 commit comments