diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-06-20 19:54:08 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-06-23 23:20:29 -0400 |
commit | d4de2cd7c73d2ab3ebe0e914ac3d223de9703c1e (patch) | |
tree | 00dd861b5a684e7c6fce2136f5cac5493e6f20d8 | |
parent | 7d604a1e6158cda79f7ac485e0ef0e349014f8bf (diff) | |
download | rneovim-d4de2cd7c73d2ab3ebe0e914ac3d223de9703c1e.tar.gz rneovim-d4de2cd7c73d2ab3ebe0e914ac3d223de9703c1e.tar.bz2 rneovim-d4de2cd7c73d2ab3ebe0e914ac3d223de9703c1e.zip |
vim-patch:8.1.0086: no tests for libcall() and libcallnr()
Problem: No tests for libcall() and libcallnr().
Solution: Add tests. (Dominique Pelle, closes vim/vim#2982)
https://github.com/vim/vim/commit/1ceebb4efc455dc6c34e0cd2c2adbd00939f038b
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index ed9c70403e..acfd4891df 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1140,3 +1140,39 @@ func Test_reg_executing_and_recording() delfunc s:save_reg_stat unlet s:reg_stat endfunc + +func Test_libcall_libcallnr() + if !has('libcall') + return + endif + + if has('win32') + let libc = 'msvcrt.dll' + elseif has('mac') + let libc = 'libSystem.B.dylib' + else + " On Unix, libc.so can be in various places. + " Interestingly, using an empty string for the 1st argument of libcall + " allows to call functions from libc which is not documented. + let libc = '' + endif + + if has('win32') + call assert_equal($USERPROFILE, libcall(libc, 'getenv', 'USERPROFILE')) + else + call assert_equal($HOME, libcall(libc, 'getenv', 'HOME')) + endif + + " If function returns NULL, libcall() should return an empty string. + call assert_equal('', libcall(libc, 'getenv', 'X_ENV_DOES_NOT_EXIT')) + + " Test libcallnr() with string and integer argument. + call assert_equal(4, libcallnr(libc, 'strlen', 'abcd')) + call assert_equal(char2nr('A'), libcallnr(libc, 'toupper', char2nr('a'))) + + call assert_fails("call libcall(libc, 'Xdoesnotexist_', '')", 'E364:') + call assert_fails("call libcallnr(libc, 'Xdoesnotexist_', '')", 'E364:') + + call assert_fails("call libcall('Xdoesnotexist_', 'getenv', 'HOME')", 'E364:') + call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", 'E364:') +endfunc |