From ad202b8401562df9c1aec75f1ad14bddea5b06d6 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 27 Feb 2017 20:50:52 -0500 Subject: vim-patch:7.4.2098 Problem: Text object tests are old style. Solution: Turn them into new style tests. (James McCoy, closes vim/vim#941) https://github.com/vim/vim/commit/00b24be454800f544676aa8850fb4378a568901e --- src/nvim/testdir/Makefile | 3 ++- src/nvim/testdir/test_textobjects.vim | 43 +++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/nvim/testdir/test_textobjects.vim (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 6f4e0fe49f..7a2360f340 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -41,13 +41,14 @@ NEW_TESTS ?= \ test_history.res \ test_increment.res \ test_increment_dbcs.res \ - test_lambda.res \ + test_lambda.res \ test_langmap.res \ test_match.res \ test_matchadd_conceal.res \ test_quickfix.res \ test_signs.res \ test_syntax.res \ + test_textobjects.res \ test_timers.res \ test_usercommands.res \ test_viml.res \ diff --git a/src/nvim/testdir/test_textobjects.vim b/src/nvim/testdir/test_textobjects.vim new file mode 100644 index 0000000000..630ae5d3a4 --- /dev/null +++ b/src/nvim/testdir/test_textobjects.vim @@ -0,0 +1,43 @@ +" Test for textobjects + +if !has('textobjects') + finish +endif + +function! CpoM(line, useM, expected) + new + + if a:useM + set cpoptions+=M + else + set cpoptions-=M + endif + + call setline(1, a:line) + + call setreg('"', '') + normal! ggfrmavi)y + call assert_equal(getreg('"'), a:expected[0]) + + call setreg('"', '') + normal! `afbmavi)y + call assert_equal(getreg('"'), a:expected[1]) + + call setreg('"', '') + normal! `afgmavi)y + call assert_equal(getreg('"'), a:expected[2]) + + q! +endfunction + +function! Test_inner_block_without_cpo_M() + call CpoM('(red \(blue) green)', 0, ['red \(blue', 'red \(blue', '']) +endfunction + +function! Test_inner_block_with_cpo_M_left_backslash() + call CpoM('(red \(blue) green)', 1, ['red \(blue) green', 'blue', 'red \(blue) green']) +endfunction + +function! Test_inner_block_with_cpo_M_right_backslash() + call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green']) +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index d6b17dc061..87acb3f361 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -342,7 +342,7 @@ static int included_patches[] = { // 2101, 2100, 2099, - // 2098, + 2098, // 2097, 2096, // 2095, -- cgit From adc6e636fea64a432656d747f3979d682c94d6e2 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 27 Feb 2017 21:02:57 -0500 Subject: vim-patch:7.4.2095 Problem: Man test fails when run with the GUI. Solution: Adjust for different behavior of GUI. Add assert_inrange(). https://github.com/vim/vim/commit/61c04493b00f85d0b97436260a9ef9ab82143b78 Only changes related to assert_inrange() were included, since we have a distinct man plugin. --- src/nvim/eval.c | 30 ++++++++++++++++++++++++++++++ src/nvim/eval.lua | 1 + src/nvim/eval_defs.h | 1 + src/nvim/version.c | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 3b8b38588b..6dc7e5606e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8111,6 +8111,30 @@ static void f_assert_fails(typval_T *argvars, typval_T *rettv, FunPtr fptr) set_vim_var_string(VV_ERRMSG, NULL, 0); } +void assert_inrange(typval_T *argvars) +{ + int error = (int)false; + varnumber_T lower = get_tv_number_chk(&argvars[0], &error); + varnumber_T upper = get_tv_number_chk(&argvars[1], &error); + varnumber_T actual = get_tv_number_chk(&argvars[2], &error); + + if (error) { + return; + } + if (actual < lower || actual > upper) { + garray_T ga; + prepare_assert_error(&ga); + + char msg[55]; + vim_snprintf(msg, sizeof(msg), "range %" PRId64 " - %" PRId64 ",", + (int64_t)lower, (int64_t)upper); + fill_assert_error(&ga, &argvars[3], (char_u *)msg, NULL, &argvars[2], + ASSERT_INRANGE); + assert_error(&ga); + ga_clear(&ga); + } +} + // Common for assert_true() and assert_false(). static void assert_bool(typval_T *argvars, bool is_true) { @@ -8158,6 +8182,12 @@ static void assert_match_common(typval_T *argvars, assert_type_T atype) } } +/// "assert_inrange(lower, upper[, msg])" function +static void f_assert_inrange(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + assert_inrange(argvars); +} + /// "assert_match(pattern, actual[, msg])" function static void f_assert_match(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index fa19ff209e..e3c5981b32 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -29,6 +29,7 @@ return { assert_exception={args={1, 2}}, assert_fails={args={1, 2}}, assert_false={args={1, 2}}, + assert_inrange={args={2, 3}}, assert_match={args={2, 3}}, assert_notequal={args={2, 3}}, assert_notmatch={args={2, 3}}, diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index fb2822b851..39028fdb11 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -278,6 +278,7 @@ typedef enum ASSERT_NOTEQUAL, ASSERT_MATCH, ASSERT_NOTMATCH, + ASSERT_INRANGE, ASSERT_OTHER, } assert_type_T; diff --git a/src/nvim/version.c b/src/nvim/version.c index 87acb3f361..46009de4ea 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -345,7 +345,7 @@ static int included_patches[] = { 2098, // 2097, 2096, - // 2095, + 2095, // 2094 NA // 2093 NA // 2092 NA -- cgit