aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-11-26 15:54:03 +0300
committerZyX <kp-pav@yandex.ru>2017-11-26 15:54:03 +0300
commitb9c78130587e42ca3b6417b47fb739a166da8eb7 (patch)
tree142cf7dd0a87dfb32a20838e7683dd1980e4b3e7 /src/nvim/testdir
parent05a3c12118a6dae0ac8f3603f9ee4d9fd9450cce (diff)
parent207b7ca4bc16d52641eaa5244eef25a0dba91dbc (diff)
downloadrneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.tar.gz
rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.tar.bz2
rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.zip
Merge branch 'master' into expression-parser
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/Makefile1
-rw-r--r--src/nvim/testdir/test_alot.vim1
-rw-r--r--src/nvim/testdir/test_autocmd.vim22
-rw-r--r--src/nvim/testdir/test_ga.vim37
-rw-r--r--src/nvim/testdir/test_stat.vim35
5 files changed, 82 insertions, 14 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index ccf999c7ee..111bd172ef 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -42,6 +42,7 @@ NEW_TESTS ?= \
test_filter_map.res \
test_fnameescape.res \
test_fold.res \
+ test_ga.res \
test_glob2regpat.res \
test_gf.res \
test_gn.res \
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index 535e290a34..c1f6405579 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -12,6 +12,7 @@ source test_filter_cmd.vim
source test_filter_map.vim
source test_float_func.vim
source test_functions.vim
+source test_ga.vim
source test_goto.vim
source test_jumps.vim
source test_fileformat.vim
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 835df42a10..82c04abf5b 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -420,3 +420,25 @@ function Test_autocmd_bufwipe_in_SessLoadPost2()
call delete(file)
endfor
endfunc
+
+func Test_Cmdline()
+ au! CmdlineEnter : let g:entered = expand('<afile>')
+ au! CmdlineLeave : let g:left = expand('<afile>')
+ let g:entered = 0
+ let g:left = 0
+ call feedkeys(":echo 'hello'\<CR>", 'xt')
+ call assert_equal(':', g:entered)
+ call assert_equal(':', g:left)
+ au! CmdlineEnter
+ au! CmdlineLeave
+
+ au! CmdlineEnter / let g:entered = expand('<afile>')
+ au! CmdlineLeave / let g:left = expand('<afile>')
+ let g:entered = 0
+ let g:left = 0
+ call feedkeys("/hello<CR>", 'xt')
+ call assert_equal('/', g:entered)
+ call assert_equal('/', g:left)
+ au! CmdlineEnter
+ au! CmdlineLeave
+endfunc
diff --git a/src/nvim/testdir/test_ga.vim b/src/nvim/testdir/test_ga.vim
new file mode 100644
index 0000000000..f9357ddc87
--- /dev/null
+++ b/src/nvim/testdir/test_ga.vim
@@ -0,0 +1,37 @@
+" Test ga normal command, and :ascii Ex command.
+func Do_ga(c)
+ call setline(1, a:c)
+ let l:a = execute("norm 1goga")
+ let l:b = execute("ascii")
+ call assert_equal(l:a, l:b)
+ return l:a
+endfunc
+
+func Test_ga_command()
+ new
+ set display=uhex
+ call assert_equal("\nNUL", Do_ga(''))
+ call assert_equal("\n<<01>> 1, Hex 01, Octal 001", Do_ga("\x01"))
+ call assert_equal("\n<<09>> 9, Hex 09, Octal 011", Do_ga("\t"))
+
+ set display=
+ call assert_equal("\nNUL", Do_ga(''))
+ call assert_equal("\n<^A> 1, Hex 01, Octal 001", Do_ga("\x01"))
+ call assert_equal("\n<^I> 9, Hex 09, Octal 011", Do_ga("\t"))
+
+ call assert_equal("\n<e> 101, Hex 65, Octal 145", Do_ga('e'))
+
+ if !has('multi_byte')
+ return
+ endif
+
+ " Test a few multi-bytes characters.
+ call assert_equal("\n<é> 233, Hex 00e9, Octal 351", Do_ga('é'))
+ call assert_equal("\n<ẻ> 7867, Hex 1ebb, Octal 17273", Do_ga('ẻ'))
+
+ " Test with combining characters.
+ call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401", Do_ga("e\u0301"))
+ call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461", Do_ga("e\u0301\u0331"))
+ call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461 < ̸> 824, Hex 0338, Octal 1470", Do_ga("e\u0301\u0331\u0338"))
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim
index 89ca9ef379..dee0d13e84 100644
--- a/src/nvim/testdir/test_stat.vim
+++ b/src/nvim/testdir/test_stat.vim
@@ -1,24 +1,24 @@
" Tests for stat functions and checktime
func Test_existent_file()
- let fname='Xtest.tmp'
+ let fname = 'Xtest.tmp'
- let ts=localtime()
- sleep 1
- let fl=['Hello World!']
+ let ts = localtime()
+ let fl = ['Hello World!']
call writefile(fl, fname)
- let tf=getftime(fname)
- sleep 1
- let te=localtime()
+ let tf = getftime(fname)
+ let te = localtime()
call assert_true(ts <= tf && tf <= te)
call assert_equal(strlen(fl[0] . "\n"), getfsize(fname))
call assert_equal('file', getftype(fname))
call assert_equal('rw-', getfperm(fname)[0:2])
+
+ call delete(fname)
endfunc
func Test_existent_directory()
- let dname='.'
+ let dname = '.'
call assert_equal(0, getfsize(dname))
call assert_equal('dir', getftype(dname))
@@ -26,22 +26,29 @@ func Test_existent_directory()
endfunc
func Test_checktime()
- let fname='Xtest.tmp'
+ let fname = 'Xtest.tmp'
- let fl=['Hello World!']
+ let fl = ['Hello World!']
call writefile(fl, fname)
set autoread
exec 'e' fname
- sleep 2
- let fl=readfile(fname)
+ " FAT has a granularity of 2 seconds, otherwise it's usually 1 second
+ if has('win32')
+ sleep 2
+ else
+ sleep 2
+ endif
+ let fl = readfile(fname)
let fl[0] .= ' - checktime'
call writefile(fl, fname)
checktime
call assert_equal(fl[0], getline(1))
+
+ call delete(fname)
endfunc
func Test_nonexistent_file()
- let fname='Xtest.tmp'
+ let fname = 'Xtest.tmp'
call delete(fname)
call assert_equal(-1, getftime(fname))
@@ -55,7 +62,7 @@ func Test_win32_symlink_dir()
" So we use an existing symlink for this test.
if has('win32')
" Check if 'C:\Users\All Users' is a symlink to a directory.
- let res=system('dir C:\Users /a')
+ let res = system('dir C:\Users /a')
if match(res, '\C<SYMLINKD> *All Users') >= 0
" Get the filetype of the symlink.
call assert_equal('dir', getftype('C:\Users\All Users'))