diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-21 14:46:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-21 14:46:19 +0200 |
| commit | 62d5137c8348e80d6231d8c7cc3784c70361030c (patch) | |
| tree | d0c339ece770bfa44f1838baaa8548180ba7d687 /src/nvim/testdir | |
| parent | 1de77bbcec8ea4e50475e9b33986246e47614b84 (diff) | |
| parent | 718702078356c4d53ef94e72662450b0971b5056 (diff) | |
| download | rneovim-62d5137c8348e80d6231d8c7cc3784c70361030c.tar.gz rneovim-62d5137c8348e80d6231d8c7cc3784c70361030c.tar.bz2 rneovim-62d5137c8348e80d6231d8c7cc3784c70361030c.zip | |
Merge #10038 from janlazo/vim-8.0.1514
vim-patch:8.0.{1514,1519},8.1.1360
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_changelist.vim | 48 | ||||
| -rw-r--r-- | src/nvim/testdir/test_substitute.vim | 18 |
2 files changed, 65 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_changelist.vim b/src/nvim/testdir/test_changelist.vim new file mode 100644 index 0000000000..dd6ea9600c --- /dev/null +++ b/src/nvim/testdir/test_changelist.vim @@ -0,0 +1,48 @@ +" Tests for the changelist functionality + +" Tests for the getchangelist() function +func Test_getchangelist() + if !has("jumplist") + return + endif + + bwipe! + enew + call assert_equal([], getchangelist(10)) + call assert_equal([[], 0], getchangelist('%')) + + call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt') + call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt') + + edit Xfile1.txt + exe "normal 1Goline\<C-G>u1.1" + exe "normal 3Goline\<C-G>u2.1" + exe "normal 5Goline\<C-G>u3.1" + normal g; + call assert_equal([[ + \ {'lnum' : 2, 'col' : 4, 'coladd' : 0}, + \ {'lnum' : 4, 'col' : 4, 'coladd' : 0}, + \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 2], + \ getchangelist('%')) + + hide edit Xfile2.txt + exe "normal 1GOline\<C-G>u1.0" + exe "normal 2Goline\<C-G>u2.0" + call assert_equal([[ + \ {'lnum' : 1, 'col' : 6, 'coladd' : 0}, + \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], + \ getchangelist('%')) + hide enew + + call assert_equal([[ + \ {'lnum' : 2, 'col' : 4, 'coladd' : 0}, + \ {'lnum' : 4, 'col' : 4, 'coladd' : 0}, + \ {'lnum' : 6, 'col' : 4, 'coladd' : 0}], 3], getchangelist(2)) + call assert_equal([[ + \ {'lnum' : 1, 'col' : 6, 'coladd' : 0}, + \ {'lnum' : 3, 'col' : 6, 'coladd' : 0}], 2], getchangelist(3)) + + bwipe! + call delete('Xfile1.txt') + call delete('Xfile2.txt') +endfunc diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index 8b306192f0..b29b678129 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -612,9 +612,24 @@ func Test_sub_replace_10() call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g')) endfunc +func Test_sub_cmd_9() + new + let input = ['1 aaa', '2 aaa', '3 aaa'] + call setline(1, input) + func Foo() + return submatch(0) + endfunc + %s/aaa/\=Foo()/gn + call assert_equal(input, getline(1, '$')) + call assert_equal(1, &modifiable) + + delfunc Foo + bw! +endfunc + func Test_nocatch_sub_failure_handling() " normal error results in all replacements - func! Foo() + func Foo() foobar endfunc new @@ -650,6 +665,7 @@ func Test_nocatch_sub_failure_handling() call assert_equal(1, error_caught) call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3)) + delfunc Foo bwipe! endfunc |