Mercurial > vim
annotate src/testdir/README.txt @ 8949:c44ab784f5e5 v7.4.1760
commit https://github.com/vim/vim/commit/4445f7ee708f1a1304526a5979c9dd9883a92a0a
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 20 20:55:56 2016 +0200
patch 7.4.1760
Problem: Compiler warning for unused variable.
Solution: Add #ifdef. (John Marriott)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 20 Apr 2016 21:00:06 +0200 |
parents | 26f555e9aab1 |
children | ea504064c996 |
rev | line source |
---|---|
6168 | 1 This directory contains tests for various Vim features. |
2 | |
7517
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
3 If it makes sense, add a new test method to an already existing file. You may |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
4 want to separate it from other tests with comment lines. |
6168 | 5 |
6 The numbered tests are older, we have switched to named tests. | |
7517
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
7 |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
8 And then you can chose between a new style test, which is a Vim script, or an |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
9 old style test, which uses Normal mode commands. Use a new style test if you |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
10 can. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
11 |
6168 | 12 |
7517
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
13 TO ADD A NEW STYLE TEST: |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
14 |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
15 1) Create a test_<subject>.vim file. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
16 2) Add test_<subject>.vim to NEW_TESTS in Make_all.mak in alphabetical order. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
17 3) Use make test_<subject>.res to run a single test in src/testdir/. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
18 Use make test_<subject> to run a single test in src/. |
6168 | 19 4) Also add an entry in src/Makefile. |
20 | |
7517
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
21 What you can use (see test_assert.vim for an example): |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
22 - Call assert_equal(), assert_true() and assert_false(). |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
23 - Use try/catch to check for exceptions. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
24 - Use alloc_fail() to have memory allocation fail. This makes it possible to |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
25 to check memory allocation failures are handled gracefully. You need to |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
26 change the source code to add an ID to the allocation. Update LAST_ID_USED |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
27 above alloc_id() to the highest ID used. |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7517
diff
changeset
|
28 - Use disable_char_avail_for_testing(1) if char_avail() must return FALSE for |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7517
diff
changeset
|
29 a while. E.g. to trigger the CursorMovedI autocommand event. |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7517
diff
changeset
|
30 See test_cursor_func.vim for an example |
7517
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
31 |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
32 |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
33 TO ADD AN OLD STYLE TEST: |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
34 |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
35 1) Create test_<subject>.in and test_<subject>.ok files. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
36 2) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
37 3) Use make test_<subject>.out to run a single test in src/testdir/. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
38 Use make test_<subject> to run a single test in src/. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
39 4) Also add an entry in src/Makefile. |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
40 |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
41 Keep in mind that the files are used as if everything was typed: |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
42 - To add comments use: :" (that's an Ex command comment) |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
43 - A line break is like pressing Enter. If that happens on the last line |
9d67399f49c6
commit https://github.com/vim/vim/commit/6602af7fe069246dbcf419c3e904a78b60e7d4dc
Christian Brabandt <cb@256bit.org>
parents:
7478
diff
changeset
|
44 you'll hear a beep! |