From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- test/old/testdir/test_put.vim | 250 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 test/old/testdir/test_put.vim (limited to 'test/old/testdir/test_put.vim') diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim new file mode 100644 index 0000000000..25fc5a2f04 --- /dev/null +++ b/test/old/testdir/test_put.vim @@ -0,0 +1,250 @@ +" Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc. + +source check.vim + +func Test_put_block() + new + call feedkeys("i\u2500\x\", 'x') + call feedkeys("\y", 'x') + call feedkeys("gg0p", 'x') + call assert_equal("\u2500x", getline(1)) + bwipe! +endfunc + +func Test_put_char_block() + new + call setline(1, ['Line 1', 'Line 2']) + f Xfile_put + " visually select both lines and put the cursor at the top of the visual + " selection and then put the buffer name over it + exe "norm! G0\ke\"%p" + call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2)) + bw! +endfunc + +func Test_put_char_block2() + new + call setreg('a', ' one ', 'v') + call setline(1, ['Line 1', '', 'Line 3', '']) + " visually select the first 3 lines and put register a over it + exe "norm! ggl\2j2l\"ap" + call assert_equal(['L one 1', '', 'L one 3', ''], getline(1, 4)) + " clean up + bw! +endfunc + +func Test_put_lines() + new + let a = [ getreg('a'), getregtype('a') ] + call setline(1, ['Line 1', 'Line2', 'Line 3', '']) + exe 'norm! gg"add"AddG""p' + call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1, '$')) + " clean up + bw! + eval a[0]->setreg('a', a[1]) +endfunc + +func Test_put_expr() + new + call setline(1, repeat(['A'], 6)) + exec "1norm! \"=line('.')\p" + norm! j0. + norm! j0. + exec "4norm! \"=\P" + norm! j0. + norm! j0. + call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1, '$')) + bw! +endfunc + +func Test_put_fails_when_nomodifiable() + new + setlocal nomodifiable + + normal! yy + call assert_fails(':put', 'E21') + call assert_fails(':put!', 'E21') + call assert_fails(':normal! p', 'E21') + call assert_fails(':normal! gp', 'E21') + call assert_fails(':normal! P', 'E21') + call assert_fails(':normal! gP', 'E21') + + if has('mouse') + set mouse=n + call assert_fails('execute "normal! \"', 'E21') + set mouse& + endif + + bwipeout! +endfunc + +" A bug was discovered where the Normal mode put commands (e.g., "p") would +" output duplicate error messages when invoked in a non-modifiable buffer. +func Test_put_p_errmsg_nodup() + new + setlocal nomodifiable + + normal! yy + + func Capture_p_error() + redir => s:p_err + normal! p + redir END + endfunc + + silent! call Capture_p_error() + + " Error message output within a function should be three lines (the function + " name, the line number, and the error message). + call assert_equal(3, count(s:p_err, "\n")) + + delfunction Capture_p_error + bwipeout! +endfunc + +func Test_put_p_indent_visual() + new + call setline(1, ['select this text', 'select that text']) + " yank "that" from the second line + normal 2Gwvey + " select "this" in the first line and put + normal k0wve[p + call assert_equal('select that text', getline(1)) + call assert_equal('select that text', getline(2)) + bwipe! +endfunc + +" Test for deleting all the contents of a buffer with a put +func Test_put_visual_delete_all_lines() + new + call setline(1, ['one', 'two', 'three']) + let @r = '' + normal! VG"rgp + call assert_equal(1, line('$')) + close! +endfunc + +func Test_gp_with_count_leaves_cursor_at_end() + new + call setline(1, '<---->') + call setreg('@', "foo\nbar", 'c') + normal 1G3|3gp + call assert_equal([0, 4, 4, 0], getpos(".")) + call assert_equal(['<--foo', 'barfoo', 'barfoo', 'bar-->'], getline(1, '$')) + call assert_equal([0, 4, 3, 0], getpos("']")) + + bwipe! +endfunc + +func Test_p_with_count_leaves_mark_at_end() + new + call setline(1, '<---->') + call setreg('@', "start\nend", 'c') + normal 1G3|3p + call assert_equal([0, 1, 4, 0], getpos(".")) + call assert_equal(['<--start', 'endstart', 'endstart', 'end-->'], getline(1, '$')) + call assert_equal([0, 4, 3, 0], getpos("']")) + + bwipe! +endfunc + +func Test_very_large_count() + new + " total put-length (21474837 * 100) brings 32 bit int overflow + let @" = repeat('x', 100) + call assert_fails('norm 21474837p', 'E1240:') + bwipe! +endfunc + +func Test_very_large_count_64bit() + throw 'Skipped: v:sizeoflong is N/A' " use legacy/put_spec.lua instead + + if v:sizeoflong < 8 + throw 'Skipped: only works with 64 bit long ints' + endif + + new + let @" = repeat('x', 100) + call assert_fails('norm 999999999p', 'E1240:') + bwipe! +endfunc + +func Test_very_large_count_block() + new + " total put-length (21474837 * 100) brings 32 bit int overflow + call setline(1, repeat('x', 100)) + exe "norm \99ly" + call assert_fails('norm 21474837p', 'E1240:') + bwipe! +endfunc + +func Test_very_large_count_block_64bit() + throw 'Skipped: v:sizeoflong is N/A' " use legacy/put_spec.lua instead + + if v:sizeoflong < 8 + throw 'Skipped: only works with 64 bit long ints' + endif + + new + call setline(1, repeat('x', 100)) + exe "norm \$y" + call assert_fails('norm 999999999p', 'E1240:') + bwipe! +endfunc + +func Test_put_above_first_line() + new + let @" = 'text' + silent! normal 0o00 + 0put + call assert_equal('text', getline(1)) + bwipe! +endfunc + +func Test_multibyte_op_end_mark() + new + call setline(1, 'ั‚ะตัั‚') + normal viwdp + call assert_equal([0, 1, 7, 0], getpos("'>")) + call assert_equal([0, 1, 7, 0], getpos("']")) + + normal Vyp + call assert_equal([0, 1, 2147483647, 0], getpos("'>")) + call assert_equal([0, 2, 7, 0], getpos("']")) + bwipe! +endfunc + +" this was putting a mark before the start of a line +func Test_put_empty_register() + new + norm yy + norm [Pi00ggv)s0 + sil! norm [P + bwipe! +endfunc + +" this was putting the end mark after the end of the line +func Test_put_visual_mode() + edit! SomeNewBuffer + set selection=exclusive + exe "norm o\t" + m0 + sil! norm  p p + + bwipe! + set selection& +endfunc + +func Test_put_visual_block_mode() + enew + exe "norm 0R\\V" + sil exe "norm \c \" + set ve=all + sil norm vz=p + + bwipe! + set ve= +endfunc + + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From 2882b1543a4f30ee3d7b039a5d51bb994fd6aa1d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 7 Mar 2023 11:04:36 +0800 Subject: vim-patch:8.2.3969: value of MAXCOL not available in Vim script Problem: Value of MAXCOL not available in Vim script. Solution: Add v:maxcol. (Naohiro Ono, closes vim/vim#9451) https://github.com/vim/vim/commit/56200eed62e59ad831f6564dcafe346e6f97ac20 The variable is always 2147483647, but introducing it makes functions easier to document. Co-authored-by: naohiro ono --- test/old/testdir/test_put.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/old/testdir/test_put.vim') diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim index 25fc5a2f04..6c7cfa09c6 100644 --- a/test/old/testdir/test_put.vim +++ b/test/old/testdir/test_put.vim @@ -209,7 +209,7 @@ func Test_multibyte_op_end_mark() call assert_equal([0, 1, 7, 0], getpos("']")) normal Vyp - call assert_equal([0, 1, 2147483647, 0], getpos("'>")) + call assert_equal([0, 1, v:maxcol, 0], getpos("'>")) call assert_equal([0, 2, 7, 0], getpos("']")) bwipe! endfunc -- cgit From 040d9da5c8f4d56e0482758223ea7bb04dc90cc0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Apr 2023 00:30:52 +0800 Subject: vim-patch:9.0.1476: lines put in non-current window are not displayed (#23265) Problem: Lines put in non-current window are not displayed. (Marius Gedminas) Solution: Don't increment the topline when inserting just above it. (closes vim/vim#12212) https://github.com/vim/vim/commit/e7f05a8780426dc7af247419c6d02d5f1e896689 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_put.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/old/testdir/test_put.vim') diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim index 6c7cfa09c6..212a979b4a 100644 --- a/test/old/testdir/test_put.vim +++ b/test/old/testdir/test_put.vim @@ -1,6 +1,7 @@ " Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc. source check.vim +source screendump.vim func Test_put_block() new @@ -246,5 +247,24 @@ func Test_put_visual_block_mode() set ve= endfunc +func Test_put_other_window() + CheckRunVimInTerminal + + let lines =<< trim END + 40vsplit + 0put ='some text at the top' + put =' one more text' + put =' two more text' + put =' three more text' + put =' four more text' + END + call writefile(lines, 'Xtest_put_other', 'D') + let buf = RunVimInTerminal('-S Xtest_put_other', #{rows: 10}) + + call VerifyScreenDump(buf, 'Test_put_other_window_1', {}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 9f3c4c152664b21593636a59ce21e74ab7000b20 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 2 Jun 2023 08:48:49 +0800 Subject: vim-patch:9.0.1597: cursor ends up below the window after a put (#23873) Problem: Cursor ends up below the window after a put. Solution: Mark w_crow and w_botline invalid when changing the cursor line. (closes vim/vim#12465) https://github.com/vim/vim/commit/8509014adda188ee8bdf6a2e123fbf15a91b29d2 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_put.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/old/testdir/test_put.vim') diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim index 212a979b4a..6c4bd28386 100644 --- a/test/old/testdir/test_put.vim +++ b/test/old/testdir/test_put.vim @@ -266,5 +266,23 @@ func Test_put_other_window() call StopVimInTerminal(buf) endfunc +func Test_put_in_last_displayed_line() + CheckRunVimInTerminal + + let lines =<< trim END + vim9script + autocmd CursorMoved * eval line('w$') + @a = 'x'->repeat(&columns * 2 - 2) + range(&lines)->setline(1) + feedkeys('G"ap') + END + call writefile(lines, 'Xtest_put_last_line', 'D') + let buf = RunVimInTerminal('-S Xtest_put_last_line', #{rows: 10}) + + call VerifyScreenDump(buf, 'Test_put_in_last_displayed_line_1', {}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit