]> granicus.if.org Git - vim/commitdiff
patch 8.0.1209: still too many old style tests v8.0.1209
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Oct 2017 12:23:59 +0000 (14:23 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Oct 2017 12:23:59 +0000 (14:23 +0200)
Problem:    Still too many old style tests.
Solution:   Convert a few more tests to new style. (Yegappan Lakshmanan,
            closes #2230)

20 files changed:
src/Makefile
src/testdir/Make_all.mak
src/testdir/Make_amiga.mak
src/testdir/Make_dos.mak
src/testdir/Make_ming.mak
src/testdir/Make_vms.mms
src/testdir/Makefile
src/testdir/main.aap
src/testdir/test34.in [deleted file]
src/testdir/test34.ok [deleted file]
src/testdir/test54.in [deleted file]
src/testdir/test54.ok [deleted file]
src/testdir/test8.in [deleted file]
src/testdir/test8.ok [deleted file]
src/testdir/test_autocmd.vim
src/testdir/test_autoformat_join.in [deleted file]
src/testdir/test_autoformat_join.ok [deleted file]
src/testdir/test_join.vim
src/testdir/test_user_func.vim [new file with mode: 0644]
src/version.c

index 7752fa17eda34355410c850a70ddcb97f0ec6f5c..a6128178a1c9a1b1f5803894fb39b8ec7c990ce2 100644 (file)
@@ -2088,9 +2088,9 @@ run_memfile_test: $(MEMFILE_TEST_TARGET)
 run_message_test: $(MESSAGE_TEST_TARGET)
        $(VALGRIND) ./$(MESSAGE_TEST_TARGET) || exit 1; echo $* passed;
 
-# Run individual OLD style test, assuming that Vim was already compiled.
+# Run individual OLD style test.
+# These do not depend on the executable, compile it when needed.
 test1 \
-       test_autoformat_join \
        test_changelist \
        test_close_count \
        test_erasebackword \
@@ -2100,20 +2100,19 @@ test1 \
        test_listchars \
        test_search_mbyte \
        test_wordcount \
-       test3 test8 \
-       test11 test12 test14 test15 test17 test19 \
+       test3 test11 test12 test14 test15 test17 test19 \
        test20 test25 test28 test29 \
-       test30 test32 test34 test36 test37 test38 test39 \
+       test30 test32 test36 test37 test38 test39 \
        test40 test42 test44 test45 test48 test49 \
-       test50 test52 test54 test55 test59 \
+       test50 test52 test55 test59 \
        test64 test66 test68 test69 \
        test70 test72 test73 test77 test79 \
        test83 test85 test86 test87 test88 \
-       test94 test95 test99 \
-       test108:
+       test94 test95 test99 test108:
        cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
 
-# Run individual NEW style test, assuming that Vim was already compiled.
+# Run individual NEW style test.
+# These do not depend on the executable, compile it when needed.
 test_arglist \
        test_arabic \
        test_assert \
index eb13761d2203f7e3c7ea28d5f8e2a5c53ecb9e94..d0afdb561411b83ee797fbb19abd877522ee4a4f 100644 (file)
@@ -14,14 +14,12 @@ SCRIPTS_FIRST = \
 # Tests that run on all systems.
 SCRIPTS_ALL = \
        test3.out \
-       test8.out \
        test14.out \
        test15.out \
        test19.out \
        test20.out \
        test28.out \
        test29.out \
-       test34.out \
        test36.out \
        test37.out \
        test38.out \
@@ -44,7 +42,6 @@ SCRIPTS_ALL = \
        test95.out \
        test99.out \
        test108.out \
-       test_autoformat_join.out \
        test_changelist.out \
        test_close_count.out \
        test_erasebackword.out \
@@ -72,11 +69,6 @@ SCRIPTS_MORE2 = \
        test49.out
 
 
-# Tests that run on most systems, but not MingW and Cygwin.
-SCRIPTS_MORE3 = \
-       test54.out
-
-
 # Tests that run on most systems, but not on VMS
 SCRIPTS_MORE4 = \
        test17.out \
@@ -187,6 +179,7 @@ NEW_TESTS = test_arabic.res \
            test_textobjects.res \
            test_undo.res \
            test_usercommands.res \
+           test_user_func.res \
            test_viminfo.res \
            test_vimscript.res \
            test_visual.res \
index 2b5d543ab1b0768341cf8090464706de64c0c1d4..7a8eca2e28b1be003cfab54316aa5aed7cb87478 100644 (file)
@@ -19,7 +19,7 @@ include Make_all.mak
 # test85       no Lua interface
 # test86, 87   no Python interface
 
-SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE3) $(SCRIPTS_MORE4)
+SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE4)
 
 # Must run test1 first to create small.vim.
 $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
index 05978ade2fad219e6209545545cd62b65a32703f..4e0c8f7dbc934f83a50c474033df20f1b21158b2 100644 (file)
@@ -17,7 +17,7 @@ default: nongui
 # test49       fails in various ways
 # test97       \{ and \$ are not escaped characters.
 
-SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE3) $(SCRIPTS_MORE4)
+SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4)
 
 TEST_OUTFILES = $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) $(SCRIPTS_GUI)
 DOSTMP = dostmp
index ecfa97e4c7f99ac17eff6ce842745bac7b0fb16c..ea748cd9399547e0f27ca74d3788e81a043c995a 100644 (file)
@@ -4,8 +4,6 @@
 #
 # Author: Bill McCarthy
 #
-# Note that test54 has been removed until it is fixed.
-#
 # Requires a set of Unix tools: echo, diff, etc.
 
 ifneq (sh.exe, $(SHELL))
@@ -35,7 +33,6 @@ include Make_all.mak
 # test10       'errorformat' is different
 # test12       can't unlink a swap file
 # test25       uses symbolic link
-# test54       doesn't work yet
 # test97       \{ and \$ are not escaped characters
 
 SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
index efed68f9ca45d6372921a47b77f057b15a5b6ec2..30b671c3543c1b9a306748fe89667ed13003f9d1 100644 (file)
@@ -74,14 +74,13 @@ VIMPROG = <->vim.exe
 .SUFFIXES : .out .in
 
 SCRIPT = test1.out test3.out \
-       test8.out  \
        test14.out test15.out \
        test19.out test20.out \
        test28.out test29.out test30.out test32.out \
-       test34.out test36.out test37.out \
+       test36.out test37.out \
        test38.out test39.out test40.out test42.out \
        test44.out test45.out \
-       test48.out test49.out test54.out \
+       test48.out test49.out \
        test55.out \
        test64.out \
        test66.out test68.out test69.out \
@@ -92,7 +91,6 @@ SCRIPT = test1.out test3.out \
        test95.out test99.out \
        test108.out\
        test_autocmd_option.out \
-       test_autoformat_join.out \
        test_breakindent.out \
        test_changelist.out \
        test_close_count.out \
index 3a69c6c1ac000ce7ad941533e0df6b13efc541bf..90e0cdb2d63e689133349eca4b6566b721379b6b 100644 (file)
@@ -24,7 +24,6 @@ include Make_all.mak
 SCRIPTS = $(SCRIPTS_ALL) \
          $(SCRIPTS_MORE1) \
          $(SCRIPTS_MORE2) \
-         $(SCRIPTS_MORE3) \
          $(SCRIPTS_MORE4)
 
 SCRIPTS_BENCH = bench_re_freeze.out
index 54f7eb256551202344f25a273a51467357a27181..51e60de82c92309f2efb09446fa35f9393f70553 100644 (file)
@@ -5,12 +5,12 @@
 VimProg ?= ../vim
 
 Scripts = test1.out test2.out test3.out test6.out
-               test8.out test11.out
+               test11.out
                test12.out  test13.out test14.out test15.out test17.out
                test18.out test19.out test20.out test21.out
                test25.out test27.out
                test28.out test29.out test30.out test32.out
-               test34.out test36.out test37.out
+               test36.out test37.out
                test38.out test39.out test40.out test42.out
                test44.out test45.out test46.out test47.out
                test48.out test49.out test74.out
diff --git a/src/testdir/test34.in b/src/testdir/test34.in
deleted file mode 100644 (file)
index 71ee5f6..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-Test for user functions.
-Also test an <expr> mapping calling a function.
-Also test that a builtin function cannot be replaced.
-Also test for regression when calling arbitrary expression.
-
-STARTTEST
-:so small.vim
-:function Table(title, ...)
-:  let ret = a:title
-:  let idx = 1
-:  while idx <= a:0
-:    exe "let ret = ret . a:" . idx
-:    let idx = idx + 1
-:  endwhile
-:  return ret
-:endfunction
-:function Compute(n1, n2, divname)
-:  if a:n2 == 0
-:    return "fail"
-:  endif
-:  exe "let g:" . a:divname . " = ". a:n1 / a:n2
-:  return "ok"
-:endfunction
-:func Expr1()
-:  normal! v
-:  return "111"
-:endfunc
-:func Expr2()
-:  call search('XX', 'b')
-:  return "222"
-:endfunc
-:func ListItem()
-:  let g:counter += 1
-:  return g:counter . '. '
-:endfunc
-:func ListReset()
-:  let g:counter = 0
-:  return ''
-:endfunc
-:func FuncWithRef(a)
-:  unlet g:FuncRef
-:  return a:a
-:endfunc
-:let g:FuncRef=function("FuncWithRef")
-:let counter = 0
-:inoremap <expr> ( ListItem()
-:inoremap <expr> [ ListReset()
-:imap <expr> + Expr1()
-:imap <expr> * Expr2()
-:let retval = "nop"
-/^here
-C\12=Table("xxx", 4, "asdf")
\12=Compute(45, 0, "retval")
\12=retval
\12=Compute(45, 5, "retval")
\12=retval
\12=g:FuncRef(333)
-
-XX+-XX
----*---
-(one
-(two
-[(one again\e:call append(line('$'), max([1, 2, 3]))
-:call extend(g:, {'max': function('min')})
-:call append(line('$'), max([1, 2, 3]))
-:try
-:    " Regression: the first line below used to throw ?E110: Missing ')'?
-:    " Second is here just to prove that this line is correct when not skipping
-:    " rhs of &&.
-:    $put =(0&&(function('tr'))(1, 2, 3))
-:    $put =(1&&(function('tr'))(1, 2, 3))
-:catch
-:    $put ='!!! Unexpected exception:'
-:    $put =v:exception
-:endtry
-:$-9,$w! test.out
-:delfunc Table
-:delfunc Compute
-:delfunc Expr1
-:delfunc Expr2
-:delfunc ListItem
-:delfunc ListReset
-:unlet retval counter
-:q!
-ENDTEST
-
-here
diff --git a/src/testdir/test34.ok b/src/testdir/test34.ok
deleted file mode 100644 (file)
index 97995de..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-xxx4asdf fail nop ok 9 333
-XX111-XX
----222---
-1. one
-2. two
-1. one again
-3
-3
-0
-1
diff --git a/src/testdir/test54.in b/src/testdir/test54.in
deleted file mode 100644 (file)
index 9fc6537..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-Some tests for buffer-local autocommands
-
-STARTTEST
-:so small.vim
-:e xx
-:if has("vms")
-: !del test.out.*
-: au BufLeave <buffer> :!write sys$output "buffer-local autommand in %" > test.out
-:else
-: !rm -f test.out
-: au BufLeave <buffer> :!echo buffer-local autommand in %>> test.out
-:endif
-:e somefile           " here, autocommand for xx shall write test.out 
-:                     " but autocommand shall not apply to buffer named <buffer>
-:bwipe xx             " here, autocommand shall be auto-deleted
-:e xx                 " nothing shall be written
-:e somefile           " nothing shall be written
-:qa!
-ENDTEST
-
-start of test file xx
-end of test file xx
diff --git a/src/testdir/test54.ok b/src/testdir/test54.ok
deleted file mode 100644 (file)
index 0fd1dc9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-buffer-local autommand in xx
diff --git a/src/testdir/test8.in b/src/testdir/test8.in
deleted file mode 100644 (file)
index d9d00d9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Test for BufWritePre autocommand that deletes or unloads the buffer.
-Test for BufUnload autocommand that unloads all other buffers.
-
-STARTTEST
-:so small.vim
-:au BufWritePre Xxx1 bunload
-:au BufWritePre Xxx2 bwipe
-/^start of
-A1\e:.,/end of/w! Xxx1  " write test file Xxx1
-$r2:.,/end of/w! Xxx2   " write test file Xxx2
-:e! Xxx2                " edit Xxx2
-:bdel test8.in         " delete this file from the buffer list
-:e Xxx1                 " edit Xxx1
-:w                      " write it, will unload it and give an error msg
-:w! test.out            " Write contents of this file
-:e! Xxx2                " start editing Xxx2
-:bwipe test.out         " remove test.out from the buffer list
-:w                      " write it, will delete the buffer and give an error msg
-:w >>test.out           " Append contents of this file
-:au! BufWritePre
-:func CloseAll()
-  let i = 0
-  while i <= bufnr('$')
-    if i != bufnr('%') && bufloaded(i)
-      exe  i . "bunload"
-    endif
-    let i += 1
-  endwhile
-endfunc
-:func WriteToOut()
-  edit! test.out
-  $put ='VimLeave done'
-  write
-endfunc
-:set viminfo='100,nviminfo
-:au BufUnload * call CloseAll()
-:au VimLeave * call WriteToOut()
-:e small.vim
-:sp mbyte.vim
-:q
-:qa!
-ENDTEST
-
-start of Xxx
-       test
-end of Xxx
diff --git a/src/testdir/test8.ok b/src/testdir/test8.ok
deleted file mode 100644 (file)
index adecb2f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-start of Xxx2
-       test
-end of Xxx
-start of Xxx1
-       test
-end of Xxx
-VimLeave done
index 6af0820eb19fcf685a7041a99a8108d66ecea7eb..6ca3b220e616cd3b0a06aac7936bd8c1d33ef66f 100644 (file)
@@ -773,6 +773,7 @@ func Test_BufLeave_Wipe()
 
   call delete('Xxx1')
   call delete('Xxx2')
+  call delete('test.out')
   %bwipe
   au! BufLeave
 
@@ -809,9 +810,93 @@ func Test_Cmdline()
   au! CmdlineLeave / let g:left = expand('<afile>')
   let g:entered = 0
   let g:left = 0
-  call feedkeys("/hello<CR>", 'xt')
+  new
+  call setline(1, 'hello')
+  call feedkeys("/hello\<CR>", 'xt')
   call assert_equal('/', g:entered)
   call assert_equal('/', g:left)
+  bwipe!
   au! CmdlineEnter
   au! CmdlineLeave
 endfunc
+
+" Test for BufWritePre autocommand that deletes or unloads the buffer.
+func Test_BufWritePre()
+  %bwipe
+  au BufWritePre Xxx1 bunload
+  au BufWritePre Xxx2 bwipe
+
+  call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1')
+  call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2')
+
+  edit Xtest
+  e! Xxx2
+  bdel Xtest
+  e Xxx1
+  " write it, will unload it and give an error msg
+  call assert_fails('w', 'E203')
+  call assert_equal('Xxx2', bufname('%'))
+  edit Xtest
+  e! Xxx2
+  bwipe Xtest
+  " write it, will delete the buffer and give an error msg
+  call assert_fails('w', 'E203')
+  call assert_equal('Xxx1', bufname('%'))
+  au! BufWritePre
+  call delete('Xxx1')
+  call delete('Xxx2')
+endfunc
+
+" Test for BufUnload autocommand that unloads all the other buffers
+func Test_bufunload_all()
+  call writefile(['Test file Xxx1'], 'Xxx1')"
+  call writefile(['Test file Xxx2'], 'Xxx2')"
+
+  let content = [
+             \ "func UnloadAllBufs()",
+             \ "  let i = 1",
+             \ "  while i <= bufnr('$')",
+             \ "    if i != bufnr('%') && bufloaded(i)",
+             \ "      exe  i . 'bunload'",
+             \ "    endif",
+             \ "    let i += 1",
+             \ "  endwhile",
+             \ "endfunc",
+             \ "au BufUnload * call UnloadAllBufs()",
+             \ "au VimLeave * call writefile(['Test Finished'], 'Xout')",
+             \ "edit Xxx1",
+             \ "split Xxx2",
+             \ "q"]
+  call writefile(content, 'Xtest')
+
+  call delete('Xout')
+  call system(v:progpath. ' --clean -N --not-a-term -S Xtest')
+  call assert_true(filereadable('Xout'))
+
+  call delete('Xxx1')
+  call delete('Xxx2')
+  call delete('Xtest')
+  call delete('Xout')
+endfunc
+
+" Some tests for buffer-local autocommands
+func Test_buflocal_autocmd()
+  let g:bname = ''
+  edit xx
+  au BufLeave <buffer> let g:bname = expand("%")
+  " here, autocommand for xx should trigger.
+  " but autocommand shall not apply to buffer named <buffer>.
+  edit somefile
+  call assert_equal('xx', g:bname)
+  let g:bname = ''
+  " here, autocommand shall be auto-deleted
+  bwipe xx
+  " autocmd should not trigger
+  edit xx
+  call assert_equal('', g:bname)
+  " autocmd should not trigger
+  edit somefile
+  call assert_equal('', g:bname)
+  enew
+  unlet g:bname
+endfunc
diff --git a/src/testdir/test_autoformat_join.in b/src/testdir/test_autoformat_join.in
deleted file mode 100644 (file)
index 16fed6d..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-Tests for setting the '[,'] marks when joining lines.
-
-STARTTEST
-:so small.vim
-:/^\t\t/
-0gqj:
-:let a=string(getpos("'[")).'/'.string(getpos("']"))
-:/^This line/;'}-join
-:let b=string(getpos("'[")).'/'.string(getpos("']"))
-:$put ='First test: Start/End '.string(a)
-:$put ='Second test: Start/End '.string(b)
-:/^\t\t/,$wq! test.out
-ENDTEST
-
-
-               O sodales, ludite, vos qui
-attamen consulite per voster honur. Tua pulchra facies me fay planszer milies
-
-This line.
-Should be joined with the next line
-and with this line
-
-Results:
diff --git a/src/testdir/test_autoformat_join.ok b/src/testdir/test_autoformat_join.ok
deleted file mode 100644 (file)
index 3b1df79..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-               O sodales, ludite, vos qui attamen consulite per voster honur.
-Tua pulchra facies me fay planszer milies
-
-This line.  Should be joined with the next line and with this line
-
-Results:
-First test: Start/End '[0, 16, 1, 0]/[0, 17, 1, 0]'
-Second test: Start/End '[0, 19, 11, 0]/[0, 19, 67, 0]'
index 8a028f1e5590ab174de824899f909df1cde8e70e..1c97414164120f98c183d11a9709899137466d8c 100644 (file)
@@ -11,3 +11,25 @@ func Test_join_with_count()
   call assert_equal('one two three four', getline(1))
   quit!
 endfunc
+
+" Tests for setting the '[,'] marks when joining lines.
+func Test_join_marks()
+  enew
+  call append(0, [
+             \ "\t\tO sodales, ludite, vos qui",
+             \ "attamen consulite per voster honur. Tua pulchra " .
+             \ "facies me fay planszer milies",
+             \ "",
+             \ "This line.",
+             \ "Should be joined with the next line",
+             \ "and with this line"])
+
+  normal gg0gqj
+  call assert_equal([0, 1, 1, 0], getpos("'["))
+  call assert_equal([0, 2, 1, 0], getpos("']"))
+
+  /^This line/;'}-join
+  call assert_equal([0, 4, 11, 0], getpos("'["))
+  call assert_equal([0, 4, 67, 0], getpos("']"))
+  enew!
+endfunc
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim
new file mode 100644 (file)
index 0000000..e7a3701
--- /dev/null
@@ -0,0 +1,96 @@
+" Test for user functions.
+" Also test an <expr> mapping calling a function.
+" Also test that a builtin function cannot be replaced.
+" Also test for regression when calling arbitrary expression.
+
+func Table(title, ...)
+  let ret = a:title
+  let idx = 1
+  while idx <= a:0
+    exe "let ret = ret . a:" . idx
+    let idx = idx + 1
+  endwhile
+  return ret
+endfunc
+
+func Compute(n1, n2, divname)
+  if a:n2 == 0
+    return "fail"
+  endif
+  exe "let g:" . a:divname . " = ". a:n1 / a:n2
+  return "ok"
+endfunc
+
+func Expr1()
+  silent! normal! v
+  return "111"
+endfunc
+
+func Expr2()
+  call search('XX', 'b')
+  return "222"
+endfunc
+
+func ListItem()
+  let g:counter += 1
+  return g:counter . '. '
+endfunc
+
+func ListReset()
+  let g:counter = 0
+  return ''
+endfunc
+
+func FuncWithRef(a)
+  unlet g:FuncRef
+  return a:a
+endfunc
+
+func Test_user_func()
+  let g:FuncRef=function("FuncWithRef")
+  let g:counter = 0
+  inoremap <expr> ( ListItem()
+  inoremap <expr> [ ListReset()
+  imap <expr> + Expr1()
+  imap <expr> * Expr2()
+  let g:retval = "nop"
+
+  call assert_equal('xxx4asdf', Table("xxx", 4, "asdf"))
+  call assert_equal('fail', Compute(45, 0, "retval"))
+  call assert_equal('nop', g:retval)
+  call assert_equal('ok', Compute(45, 5, "retval"))
+  call assert_equal(9, g:retval)
+  call assert_equal(333, g:FuncRef(333))
+
+  enew
+
+  normal oXX+-XX
+  call assert_equal('XX111-XX', getline('.'))
+  normal o---*---
+  call assert_equal('---222---', getline('.'))
+  normal o(one
+  call assert_equal('1. one', getline('.'))
+  normal o(two
+  call assert_equal('2. two', getline('.'))
+  normal o[(one again
+  call assert_equal('1. one again', getline('.'))
+
+  call assert_equal(3, max([1, 2, 3]))
+  call assert_fails("call extend(g:, {'max': function('min')})", 'E704')
+  call assert_equal(3, max([1, 2, 3]))
+
+  " Regression: the first line below used to throw ?E110: Missing ')'?
+  " Second is here just to prove that this line is correct when not skipping
+  " rhs of &&.
+  call assert_equal(0, (0 && (function('tr'))(1, 2, 3)))
+  call assert_equal(1, (1 && (function('tr'))(1, 2, 3)))
+
+  delfunc Table
+  delfunc Compute
+  delfunc Expr1
+  delfunc Expr2
+  delfunc ListItem
+  delfunc ListReset
+  unlet g:retval g:counter
+  enew!
+endfunc
index d9a3fdb0a08de2f6c8d7d883efa4a48afc63b7f1..b0eefff0212edf404535bb3fa0d7520cb66c4fad 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1209,
 /**/
     1208,
 /**/