From f8f07891e7f232052e4a1107e941c62b560b52ec Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 11 Mar 2015 00:56:53 -0400 Subject: tests: add missing "_spec" suffix --- .../legacy/005_bufleave_delete_buffer.lua | 71 ----------- .../legacy/005_bufleave_delete_buffer_spec.lua | 71 +++++++++++ test/functional/legacy/100_undo_level.lua | 142 --------------------- test/functional/legacy/100_undo_level_spec.lua | 142 +++++++++++++++++++++ test/functional/legacy/103_visual_mode_reset.lua | 47 ------- .../legacy/103_visual_mode_reset_spec.lua | 47 +++++++ test/functional/legacy/104_let_assignment.lua | 54 -------- test/functional/legacy/104_let_assignment_spec.lua | 54 ++++++++ 8 files changed, 314 insertions(+), 314 deletions(-) delete mode 100644 test/functional/legacy/005_bufleave_delete_buffer.lua create mode 100644 test/functional/legacy/005_bufleave_delete_buffer_spec.lua delete mode 100644 test/functional/legacy/100_undo_level.lua create mode 100644 test/functional/legacy/100_undo_level_spec.lua delete mode 100644 test/functional/legacy/103_visual_mode_reset.lua create mode 100644 test/functional/legacy/103_visual_mode_reset_spec.lua delete mode 100644 test/functional/legacy/104_let_assignment.lua create mode 100644 test/functional/legacy/104_let_assignment_spec.lua diff --git a/test/functional/legacy/005_bufleave_delete_buffer.lua b/test/functional/legacy/005_bufleave_delete_buffer.lua deleted file mode 100644 index e8459ad4a7..0000000000 --- a/test/functional/legacy/005_bufleave_delete_buffer.lua +++ /dev/null @@ -1,71 +0,0 @@ --- Test for autocommand that deletes the current buffer on BufLeave event. --- Also test deleting the last buffer, should give a new, empty buffer. - -local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect - -describe('test5', function() - setup(clear) - - it('is working', function() - insert([[ - start of test file Xxx - vim: set noai : - this is a test - this is a test - this is a test - this is a test - end of test file Xxx]]) - - execute('w! Xxx0') - execute('au BufLeave Xxx bwipe') - execute('/start of') - - -- Write test file Xxx. - execute('.,/end of/w! Xxx') - - -- Split to Xxx. - execute('sp Xxx') - - -- Delete buffer Xxx, now we're back here. - execute('bwipe') - feed('G?this is a') - feed('othis is some more text') - - -- Append some text to this file. - - -- Write current file contents. - execute('?start?,$yank A') - - -- Delete alternate buffer. - execute('bwipe test.out') - execute('au bufleave test5.in bwipe') - - -- Delete current buffer, get an empty one. - execute('bwipe!') - feed('ithis is another test line:yank A') - - -- Output results - execute('%d') - execute('0put a') - execute('1d | $d') - - -- Assert buffer contents. - expect([[ - start of test file Xxx - vim: set noai : - this is a test - this is a test - this is a test - this is a test - this is some more text - end of test file Xxx - this is another test line]]) - end) - - teardown(function() - os.remove('Xxx') - os.remove('Xxx0') - end) -end) diff --git a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua new file mode 100644 index 0000000000..e8459ad4a7 --- /dev/null +++ b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua @@ -0,0 +1,71 @@ +-- Test for autocommand that deletes the current buffer on BufLeave event. +-- Also test deleting the last buffer, should give a new, empty buffer. + +local helpers = require('test.functional.helpers') +local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local execute, expect = helpers.execute, helpers.expect + +describe('test5', function() + setup(clear) + + it('is working', function() + insert([[ + start of test file Xxx + vim: set noai : + this is a test + this is a test + this is a test + this is a test + end of test file Xxx]]) + + execute('w! Xxx0') + execute('au BufLeave Xxx bwipe') + execute('/start of') + + -- Write test file Xxx. + execute('.,/end of/w! Xxx') + + -- Split to Xxx. + execute('sp Xxx') + + -- Delete buffer Xxx, now we're back here. + execute('bwipe') + feed('G?this is a') + feed('othis is some more text') + + -- Append some text to this file. + + -- Write current file contents. + execute('?start?,$yank A') + + -- Delete alternate buffer. + execute('bwipe test.out') + execute('au bufleave test5.in bwipe') + + -- Delete current buffer, get an empty one. + execute('bwipe!') + feed('ithis is another test line:yank A') + + -- Output results + execute('%d') + execute('0put a') + execute('1d | $d') + + -- Assert buffer contents. + expect([[ + start of test file Xxx + vim: set noai : + this is a test + this is a test + this is a test + this is a test + this is some more text + end of test file Xxx + this is another test line]]) + end) + + teardown(function() + os.remove('Xxx') + os.remove('Xxx0') + end) +end) diff --git a/test/functional/legacy/100_undo_level.lua b/test/functional/legacy/100_undo_level.lua deleted file mode 100644 index 9143d9e540..0000000000 --- a/test/functional/legacy/100_undo_level.lua +++ /dev/null @@ -1,142 +0,0 @@ --- Tests for 'undolevel' setting being global-local - -local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect - -describe('undolevel', function() - setup(clear) - - it('is working', function() - source([[ - set ul=5 - fu! FillBuffer() - for i in range(1,13) - put=i - exe "setg ul=" . &g:ul - endfor - endfu - fu! UndoLevel() - redir @z - setglobal undolevels? - echon ' global' - setlocal undolevels? - echon ' local' - redir end - $put z - endfu - - 0put ='ONE: expecting global undolevels: 5, local undolevels: -123456 (default)' - call FillBuffer() - setlocal undolevels< - earlier 10 - call UndoLevel() - set ff=unix - %yank A - %delete - - 0put ='TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)' - setlocal ul=2 - call FillBuffer() - earlier 10 - call UndoLevel() - setlocal ul=10 - call UndoLevel() - set ff=unix - %yank A - %delete - setlocal undolevels< - redir @A - echo "global value shouldn't be changed and still be 5!" - echo 'ONE: expecting global undolevels: 5, local undolevels: -123456 (default)' - setglobal undolevels? - echon ' global' - setlocal undolevels? - echon ' local' - echo "" - redir end - - setglobal ul=50 - 1put ='global value should be changed to 50' - 2put ='THREE: expecting global undolevels: 50, local undolevels: -123456 (default)' - call UndoLevel() - set ff=unix - %yank A - %delete - setglobal lispwords=foo,bar,baz - setlocal lispwords-=foo - setlocal lispwords+=quux - redir @A - echo "Testing 'lispwords' local value" - setglobal lispwords? - setlocal lispwords? - echo &lispwords - echo '' - redir end - setlocal lispwords< - redir @A - echo "Testing 'lispwords' value reset" - setglobal lispwords? - setlocal lispwords? - echo &lispwords - redir end - - 0put a - $d - ]]) - - -- Assert buffer contents. - expect([[ - ONE: expecting global undolevels: 5, local undolevels: -123456 (default) - 1 - 2 - 3 - 4 - 5 - 6 - 7 - - - undolevels=5 global - undolevels=-123456 local - TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards) - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - undolevels=5 global - undolevels=2 local - - undolevels=5 global - undolevels=10 local - - global value shouldn't be changed and still be 5! - ONE: expecting global undolevels: 5, local undolevels: -123456 (default) - undolevels=5 global - undolevels=-123456 local - - global value should be changed to 50 - THREE: expecting global undolevels: 50, local undolevels: -123456 (default) - - undolevels=50 global - undolevels=-123456 local - - Testing 'lispwords' local value - lispwords=foo,bar,baz - lispwords=bar,baz,quux - bar,baz,quux - - Testing 'lispwords' value reset - lispwords=foo,bar,baz - lispwords=foo,bar,baz - foo,bar,baz]]) - end) -end) diff --git a/test/functional/legacy/100_undo_level_spec.lua b/test/functional/legacy/100_undo_level_spec.lua new file mode 100644 index 0000000000..9143d9e540 --- /dev/null +++ b/test/functional/legacy/100_undo_level_spec.lua @@ -0,0 +1,142 @@ +-- Tests for 'undolevel' setting being global-local + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('undolevel', function() + setup(clear) + + it('is working', function() + source([[ + set ul=5 + fu! FillBuffer() + for i in range(1,13) + put=i + exe "setg ul=" . &g:ul + endfor + endfu + fu! UndoLevel() + redir @z + setglobal undolevels? + echon ' global' + setlocal undolevels? + echon ' local' + redir end + $put z + endfu + + 0put ='ONE: expecting global undolevels: 5, local undolevels: -123456 (default)' + call FillBuffer() + setlocal undolevels< + earlier 10 + call UndoLevel() + set ff=unix + %yank A + %delete + + 0put ='TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)' + setlocal ul=2 + call FillBuffer() + earlier 10 + call UndoLevel() + setlocal ul=10 + call UndoLevel() + set ff=unix + %yank A + %delete + setlocal undolevels< + redir @A + echo "global value shouldn't be changed and still be 5!" + echo 'ONE: expecting global undolevels: 5, local undolevels: -123456 (default)' + setglobal undolevels? + echon ' global' + setlocal undolevels? + echon ' local' + echo "" + redir end + + setglobal ul=50 + 1put ='global value should be changed to 50' + 2put ='THREE: expecting global undolevels: 50, local undolevels: -123456 (default)' + call UndoLevel() + set ff=unix + %yank A + %delete + setglobal lispwords=foo,bar,baz + setlocal lispwords-=foo + setlocal lispwords+=quux + redir @A + echo "Testing 'lispwords' local value" + setglobal lispwords? + setlocal lispwords? + echo &lispwords + echo '' + redir end + setlocal lispwords< + redir @A + echo "Testing 'lispwords' value reset" + setglobal lispwords? + setlocal lispwords? + echo &lispwords + redir end + + 0put a + $d + ]]) + + -- Assert buffer contents. + expect([[ + ONE: expecting global undolevels: 5, local undolevels: -123456 (default) + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + undolevels=5 global + undolevels=-123456 local + TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards) + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + undolevels=5 global + undolevels=2 local + + undolevels=5 global + undolevels=10 local + + global value shouldn't be changed and still be 5! + ONE: expecting global undolevels: 5, local undolevels: -123456 (default) + undolevels=5 global + undolevels=-123456 local + + global value should be changed to 50 + THREE: expecting global undolevels: 50, local undolevels: -123456 (default) + + undolevels=50 global + undolevels=-123456 local + + Testing 'lispwords' local value + lispwords=foo,bar,baz + lispwords=bar,baz,quux + bar,baz,quux + + Testing 'lispwords' value reset + lispwords=foo,bar,baz + lispwords=foo,bar,baz + foo,bar,baz]]) + end) +end) diff --git a/test/functional/legacy/103_visual_mode_reset.lua b/test/functional/legacy/103_visual_mode_reset.lua deleted file mode 100644 index 6b2f3bc1b6..0000000000 --- a/test/functional/legacy/103_visual_mode_reset.lua +++ /dev/null @@ -1,47 +0,0 @@ --- Test for visual mode not being reset causing E315 error. - -local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect - -describe('E315 error', function() - setup(clear) - - it('is working', function() - -- At this point there is no visual selection because :call reset it. - -- Let's restore the selection: - source([[ - let g:msg="Everything's fine." - function! TriggerTheProblem() - normal gv - '<,'>del _ - try - exe "normal \" - catch /^Vim\%((\a\+)\)\=:E315/ - echom 'Snap! E315 error!' - let g:msg='Snap! E315 error!' - endtry - endfunction - enew - enew - setl buftype=nofile - call append(line('$'), 'Delete this line.') - ]]) - - -- NOTE: this has to be done by a call to a function because executing - -- :del the ex-way will require the colon operator which resets the - -- visual mode thus preventing the problem: - feed('GV:call TriggerTheProblem()') - - source([[ - %del _ - call append(line('$'), g:msg) - brewind - ]]) - - -- Assert buffer contents. - expect([[ - - Everything's fine.]]) - end) -end) diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua new file mode 100644 index 0000000000..6b2f3bc1b6 --- /dev/null +++ b/test/functional/legacy/103_visual_mode_reset_spec.lua @@ -0,0 +1,47 @@ +-- Test for visual mode not being reset causing E315 error. + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('E315 error', function() + setup(clear) + + it('is working', function() + -- At this point there is no visual selection because :call reset it. + -- Let's restore the selection: + source([[ + let g:msg="Everything's fine." + function! TriggerTheProblem() + normal gv + '<,'>del _ + try + exe "normal \" + catch /^Vim\%((\a\+)\)\=:E315/ + echom 'Snap! E315 error!' + let g:msg='Snap! E315 error!' + endtry + endfunction + enew + enew + setl buftype=nofile + call append(line('$'), 'Delete this line.') + ]]) + + -- NOTE: this has to be done by a call to a function because executing + -- :del the ex-way will require the colon operator which resets the + -- visual mode thus preventing the problem: + feed('GV:call TriggerTheProblem()') + + source([[ + %del _ + call append(line('$'), g:msg) + brewind + ]]) + + -- Assert buffer contents. + expect([[ + + Everything's fine.]]) + end) +end) diff --git a/test/functional/legacy/104_let_assignment.lua b/test/functional/legacy/104_let_assignment.lua deleted file mode 100644 index a2431da835..0000000000 --- a/test/functional/legacy/104_let_assignment.lua +++ /dev/null @@ -1,54 +0,0 @@ --- Tests for :let. - -local helpers = require('test.functional.helpers') -local clear, source = helpers.clear, helpers.source -local execute, expect = helpers.execute, helpers.expect - -describe(':let', function() - setup(clear) - - it('is working', function() - execute('set runtimepath+=test/functional/fixtures') - - -- Test to not autoload when assigning. It causes internal error. - source([[ - try - let Test104#numvar = function('tr') - $put ='OK: ' . string(Test104#numvar) - catch - $put ='FAIL: ' . v:exception - endtry - let a = 1 - let b = 2 - for letargs in ['a b', '{0 == 1 ? "a" : "b"}', '{0 == 1 ? "a" : "b"} a', 'a {0 == 1 ? "a" : "b"}'] - try - redir => messages - execute 'let' letargs - redir END - $put ='OK:' - $put =split(substitute(messages, '\n', '\0 ', 'g'), '\n') - catch - $put ='FAIL: ' . v:exception - redir END - endtry - endfor]]) - - -- Remove empty line - execute('1d') - - -- Assert buffer contents. - expect([[ - OK: function('tr') - OK: - a #1 - b #2 - OK: - b #2 - OK: - b #2 - a #1 - OK: - a #1 - b #2]]) - end) -end) diff --git a/test/functional/legacy/104_let_assignment_spec.lua b/test/functional/legacy/104_let_assignment_spec.lua new file mode 100644 index 0000000000..a2431da835 --- /dev/null +++ b/test/functional/legacy/104_let_assignment_spec.lua @@ -0,0 +1,54 @@ +-- Tests for :let. + +local helpers = require('test.functional.helpers') +local clear, source = helpers.clear, helpers.source +local execute, expect = helpers.execute, helpers.expect + +describe(':let', function() + setup(clear) + + it('is working', function() + execute('set runtimepath+=test/functional/fixtures') + + -- Test to not autoload when assigning. It causes internal error. + source([[ + try + let Test104#numvar = function('tr') + $put ='OK: ' . string(Test104#numvar) + catch + $put ='FAIL: ' . v:exception + endtry + let a = 1 + let b = 2 + for letargs in ['a b', '{0 == 1 ? "a" : "b"}', '{0 == 1 ? "a" : "b"} a', 'a {0 == 1 ? "a" : "b"}'] + try + redir => messages + execute 'let' letargs + redir END + $put ='OK:' + $put =split(substitute(messages, '\n', '\0 ', 'g'), '\n') + catch + $put ='FAIL: ' . v:exception + redir END + endtry + endfor]]) + + -- Remove empty line + execute('1d') + + -- Assert buffer contents. + expect([[ + OK: function('tr') + OK: + a #1 + b #2 + OK: + b #2 + OK: + b #2 + a #1 + OK: + a #1 + b #2]]) + end) +end) -- cgit From 3de0f5654b2547bfdfbb92d3abffb7b87d50539c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 11 Mar 2015 01:47:38 -0400 Subject: tests: fix 005_bufleave_delete_buffer_spec.lua - After _spec suffix was added so busted could find the test, it failed. - The original legacy test wrote to a "test.out", but the new test uses register @A. - Original test did not contain 1d and new test shouldn't either. ref c152cdd0f34c10b3d3a8007838561556578685c6 --- test/functional/legacy/005_bufleave_delete_buffer_spec.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua index e8459ad4a7..e6989a6674 100644 --- a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua +++ b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua @@ -38,18 +38,15 @@ describe('test5', function() -- Write current file contents. execute('?start?,$yank A') - -- Delete alternate buffer. - execute('bwipe test.out') - execute('au bufleave test5.in bwipe') - -- Delete current buffer, get an empty one. execute('bwipe!') + -- Append an extra line to the output register. feed('ithis is another test line:yank A') -- Output results execute('%d') execute('0put a') - execute('1d | $d') + execute('$d') -- Assert buffer contents. expect([[ -- cgit