Commit Graph

7929 Commits

Author SHA1 Message Date
ZyX
fa852e7cdc eval: Fix extend() behaviour with NULL lists and dictionaries
Ref #4615
Ref vim/vim#768
2017-03-29 10:08:45 +03:00
ZyX
4987850cac unittests: Add tv_dict_clear tests 2017-03-29 10:08:45 +03:00
ZyX
43e9fad1c8 eval: Use tv_is_func in place of ==VAR_FUNC||==VAR_PARTIAL
Also fixes same error as in vim/vim#1557
2017-03-29 10:08:45 +03:00
ZyX
270a3889af unittests: Add tv_dict_add* unit tests
Also fixes incorrect location of `tv_dict_add` function and three bugs in other 
functions:

1. `tv_dict_add_list` may free list it does not own (vim/vim#1555).
2. `tv_dict_add_dict` may free dictionary it does not own (vim/vim#1555).
3. `tv_dict_add_dict` ignores `key_len` argument.
2017-03-29 10:08:45 +03:00
ZyX
bc87d23c28 unittests: Add tests for dictionary indexing 2017-03-29 10:08:45 +03:00
ZyX
b222453c95 eval/typval: Refactor errors a bit: use emsgf always 2017-03-29 10:08:45 +03:00
ZyX
5ce6243241 unittests: Enable tv_list_join tests back
Unable to reproduce the problem on Mac OS X Sierra VPS, need to check whether it 
is reproducible on travis.
2017-03-29 10:08:45 +03:00
ZyX
52e226ff74 unittests: Disable tv_list_join test on Mac OS only 2017-03-29 10:08:45 +03:00
ZyX
f830243ff7 mbyte: Include os_defs.h in mbyte.h 2017-03-29 10:08:45 +03:00
ZyX
3bf87a5a6b eval: Do not use S_LEN as snprintf argument 2017-03-29 10:08:45 +03:00
ZyX
38dd81c136 eval/typval: Fix SEGV in test_alot.vim test 2017-03-29 10:08:45 +03:00
ZyX
faddd83db8 eval: Fix SEGV in test49 2017-03-29 10:08:45 +03:00
ZyX
6c622ed08b unittests: Add tv_dict_item_{add,remove} tests 2017-03-29 10:08:45 +03:00
ZyX
ffaf7c7521 unittests: Add tv_dict_item_{alloc,free} tests 2017-03-29 10:08:45 +03:00
ZyX
cdb1aa3e47 eval: Fix len argument to xstrlcat 2017-03-29 10:08:45 +03:00
ZyX
2c8ad27652 ascii: Readd DEL_STR define 2017-03-29 10:08:45 +03:00
ZyX
c6c48e8672 syntax: Fix linter error 2017-03-29 10:08:45 +03:00
ZyX
78a0de2c1b eval/typval: Fix -Werror=return-type 2017-03-29 10:08:45 +03:00
ZyX
4c3be98db9 unittests: Add tv_dict_watcher_{add,remove} tests 2017-03-29 10:08:45 +03:00
ZyX
140174669e unittests: Run tv_list_join tests in case it stopped failing 2017-03-29 10:08:45 +03:00
ZyX
6aa6e50075 eval: Fix linter errors 2017-03-29 10:08:45 +03:00
ZyX
506b938947 *: Make some more things const and with length 2017-03-29 10:08:44 +03:00
ZyX
3025431c81 eval: Make sure that v:_null_dict does not crash dictwatcher*()
Ref #4615
2017-03-29 10:08:44 +03:00
ZyX
a56f2d27e3 eval: Make dictionary watchers work with empty keys
Looks like dict_notifications_spec test used to depend on some state which
should not be preserved. Changed all `setup()` calls to `before_each()` and
added necessary state in addition to changes required to test empty keys.

Note: unit tests for tv_dict_watcher* are still needed.
2017-03-29 10:08:44 +03:00
ZyX
1e3e302dc2 eval: Move part of dictwatcher* functions to eval/typval 2017-03-29 10:08:44 +03:00
ZyX
5239616297 functests: Fix buf_functions test on Windows 2017-03-29 10:08:44 +03:00
ZyX
4bcee96347 *: Fix some Windows-specific warnings
Also fixed an error in path_fnamecmp().
2017-03-29 10:08:42 +03:00
ZyX
9ed9af7e11 eval/typval: More const qualifiers in tv_dict* function signatures 2017-03-29 10:08:06 +03:00
ZyX
56e51033ab unittests: Add tests for tv_list_idx_of_item 2017-03-29 10:08:06 +03:00
ZyX
e5edf07ec4 unittests: Add tests for tv_list_find*() functions
Additional modifications:

- More `const` qualifiers in tested functions.
- `tv_list_find_str()` second argument is more in-line with other
  `tv_list_find*()` functions.
2017-03-29 10:08:06 +03:00
ZyX
b3672ae2fc eval/typval: Add tv_list_equal() tests, compare NULL lists equal 2017-03-29 10:08:06 +03:00
ZyX
4f9e784427 unittests: Test tv_list_join() 2017-03-29 10:08:06 +03:00
ZyX
cf45c7bb05 unittests: Fix tests crash
Tests crash at some point without
- `after_each(collectgarbage)` right before “typval.c list copy() copies list
  correctly and converts items” test.
- Commenting out that test.
- Adding `collectgarbage()` after the test (what actually this commit does).

Adding `collectgarbage()` to top-level `after_each` block right after
`restore_allocators` makes running this file crash even if it is run alone.
2017-03-29 10:08:06 +03:00
ZyX
7ceebacb3f eval/typval,tests: Fix extending list with itself, add tests
Adds unit test for tv_list_extend and regression test for extend() VimL
function.
2017-03-29 10:08:06 +03:00
ZyX
56e4c2f67e unittests: Test tv_list_concat() 2017-03-29 10:08:06 +03:00
ZyX
f80a00469f eval/typval: Make tv_list_concat handle NULL lists correctly
Fixes some FIXMEs in eval/null_spec.lua.
2017-03-29 10:08:06 +03:00
ZyX
82e6cac5f9 functests: Add null_spec.lua from #4615
For now it is full of FIXMEs and tests for incorrect behaviour. Sorted out to
have FIXMEs in one place, commented crashing tests in other and correctly
working tests in the third one.
2017-03-29 10:08:06 +03:00
ZyX
9898f36aa3 unittests: Test tv_list_copy
Also found some bugs:

1. var_item_copy() always fails to copy v:_null_list and v:_null_dict. Fixing
   this should mean fixing `deepcopy(v:_null_list)` which should’ve been, but
   was not listed in #4615. This also fixes `deepcopy(v:_null_dict)`.
2. var_item_copy() crashes when trying to copy NULL string with `conv != NULL`.
3. `conv` argument is ignored when copying list unless `deep` is true, but it
   was not reflected in documentation.
4. `tv_dict_item_alloc_len()` allocated more memory then needed.
5. typvalt2lua was not able to handle self-referencing containers.
2017-03-29 10:08:06 +03:00
ZyX
9b8beaff02 unittests: Add tests for tv_list_insert*()/…append*() functions 2017-03-29 10:08:06 +03:00
ZyX
be360d8841 unittests: Add tests for tv_list_insert() 2017-03-29 10:08:06 +03:00
ZyX
d2639e1e1d unittests: Add tests for list watchers and list alloc/free/unref 2017-03-29 10:08:06 +03:00
ZyX
a394167177 unittests: Test tv_list_item_\* functions
To check that memory is free()d correctly.
2017-03-29 10:08:06 +03:00
ZyX
a32db8ed19 eval/typval: Add missing includes, also add a script to find them
Contains unfinished attempt to integrate IWYU (ref #549). To finish it different
job should be done, specifically:

- Instead of feeding IWYU with modified file a mirror source tree should be
  created with the help of CMake which will contain modified sources. This
  solves the problem with IWYU thinking that `*.generated.h` headers should be
  included in place of `*` headers.
- Build IWYU as all other third-party utilities.
- Make modified sources avoid problems with `nvim/func_attr.h` includes and
  various related tricks.

Current script may only be used for manual checks like this:

    ./scripts/check-includes.py \
        --generated-includes-dir build/include \
        --generated-includes-dir build/src/nvim/auto \
        --file src/nvim/eval/typval.c \
        -- -Isrc -Ibuild/include -Ibuild/src/nvim/auto \
           -DINCLUDE_GENERATED_DECLARATIONS

(it is also somewhat fine with `--file src/nvim/eval/typval.h`). I have no idea
why (I mean, why developer think that these lines are needed, why they are
suggested is pretty obvious: because there is typedef which mentions them before
structs are defined), but for typval.h it reports, among other things, that it
should add lines

    struct dictvar_S;
    struct listitem_S;
    struct listvar_S;
    struct listwatch_S;
2017-03-29 10:08:06 +03:00
ZyX
2ad4fba46d eval: Move copy_tv to eval/typval 2017-03-29 10:08:06 +03:00
ZyX
8b0fa64ed3 message: Remove incorrect assertion
It was there only to prove that *now* `len` argument is not used to forbid 
putting message into history (i.e. that Neovim behaviour did not change). After 
this commit it should be possible to use msg_puts_attr_len with len>=0 to put 
message into history should new code need this.
2017-03-29 10:08:06 +03:00
ZyX
40feac6efc message: Revise maxlen argument in msg_puts_attr_len
`attr` argument is enough to forbid putting message in history. Also forbid 
strings with NUL before `len` just in case (it appears that this does not ever 
happen).
2017-03-29 10:08:06 +03:00
ZyX
3a3816c990 cmake: Use CMAKE_CURRENT_LIST_DIR and remove vars used only once 2017-03-29 10:08:06 +03:00
ZyX
86fc4580b8 eval: Fix max_min functions
Found two bugs:

1. Multiple unneeded error messages, vim/vim#1039.
2. Unformatted error string, vim/vim#1040.
2017-03-29 10:08:06 +03:00
ZyX
c4fe656fef typval.h: Allow non-var expressions in TV_DICT_ITER first argument 2017-03-29 10:08:06 +03:00
ZyX
6cc3d59ec8 misc1: Refactor ask_yesno() 2017-03-29 10:08:06 +03:00