Patch 7.4.2163
Problem: match() and related functions tested with old style test.
Solution: Convert to new style test. (Hirohito Higashi)
Files: src/Makefile, src/testdir/Make_all.mak, src/testdir/test63.in,
src/testdir/test63.ok, src/testdir/test_alot.vim,
src/testdir/test_match.vim, src/testdir/test_matchstrpos.vim
*** ../vim-7.4.2162/src/Makefile 2016-08-05 19:31:37.644426151 +0200
--- src/Makefile 2016-08-06 14:57:01.053232619 +0200
***************
*** 2044,2050 ****
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
test40 test41 test42 test43 test44 test45 test46 test48 test49 \
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
! test60 test62 test63 test64 test65 test66 test67 test68 test69 \
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \
test90 test91 test92 test93 test94 test95 test97 test98 test99 \
--- 2044,2050 ----
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
test40 test41 test42 test43 test44 test45 test46 test48 test49 \
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
! test60 test62 test64 test65 test66 test67 test68 test69 \
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \
test90 test91 test92 test93 test94 test95 test97 test98 test99 \
***************
*** 2095,2103 ****
test_largefile \
test_lispwords \
test_man \
test_matchadd_conceal \
test_matchadd_conceal_utf8 \
- test_matchstrpos \
test_menu \
test_messages \
test_netbeans \
--- 2095,2103 ----
test_largefile \
test_lispwords \
test_man \
+ test_match \
test_matchadd_conceal \
test_matchadd_conceal_utf8 \
test_menu \
test_messages \
test_netbeans \
*** ../vim-7.4.2162/src/testdir/Make_all.mak 2016-08-05 19:31:37.644426151
+0200
--- src/testdir/Make_all.mak 2016-08-06 14:57:01.053232619 +0200
***************
*** 51,57 ****
test57.out \
test60.out \
test62.out \
- test63.out \
test64.out \
test65.out \
test66.out \
--- 51,56 ----
*** ../vim-7.4.2162/src/testdir/test63.in 2015-06-19 16:32:52.328116933
+0200
--- src/testdir/test63.in 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,200 ****
- Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
- "matchadd()", "matchaddpos", "matcharg()", "matchdelete()", and
"setmatches()".
-
- STARTTEST
- :so small.vim
- :set encoding=utf8
- :" --- Check that "matcharg()" returns the correct group and pattern if a
match
- :" --- is defined.
- :let @r = "*** Test 1: "
- :highlight MyGroup1 term=bold ctermbg=red guibg=red
- :highlight MyGroup2 term=italic ctermbg=green guibg=green
- :highlight MyGroup3 term=underline ctermbg=blue guibg=blue
- :match MyGroup1 /TODO/
- :2match MyGroup2 /FIXME/
- :3match MyGroup3 /XXX/
- :if matcharg(1) == ['MyGroup1', 'TODO'] && matcharg(2) == ['MyGroup2',
'FIXME'] && matcharg(3) == ['MyGroup3', 'XXX']
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :" --- Check that "matcharg()" returns an empty list if the argument is not 1,
- :" --- 2 or 3 (only 0 and 4 are tested).
- :let @r .= "*** Test 2: "
- :if matcharg(0) == [] && matcharg(4) == []
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :" --- Check that "matcharg()" returns ['', ''] if a match is not defined.
- :let @r .= "*** Test 3: "
- :match
- :2match
- :3match
- :if matcharg(1) == ['', ''] && matcharg(2) == ['', ''] && matcharg(3) == ['',
'']
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :" --- Check that "matchadd()" and "getmatches()" agree on added matches and
- :" --- that default values apply.
- :let @r .= "*** Test 4: "
- :let m1 = matchadd("MyGroup1", "TODO")
- :let m2 = matchadd("MyGroup2", "FIXME", 42)
- :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
- :if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10,
'id': 4}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5},
{'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :" --- Check that "matchdelete()" deletes the matches defined in the previous
- :" --- test correctly.
- :let @r .= "*** Test 5: "
- :call matchdelete(m1)
- :call matchdelete(m2)
- :call matchdelete(m3)
- :unlet m1
- :unlet m2
- :unlet m3
- :if getmatches() == []
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :" --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
- :let @r .= "*** Test 6: "
- :let m = matchadd("MyGroup1", "TODO")
- :let r1 = matchdelete(m)
- :let r2 = matchdelete(42)
- :if r1 == 0 && r2 == -1
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :unlet m
- :unlet r1
- :unlet r2
- :" --- Check that "clearmatches()" clears all matches defined by ":match" and
- :" --- "matchadd()".
- :let @r .= "*** Test 7: "
- :let m1 = matchadd("MyGroup1", "TODO")
- :let m2 = matchadd("MyGroup2", "FIXME", 42)
- :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
- :match MyGroup1 /COFFEE/
- :2match MyGroup2 /HUMPPA/
- :3match MyGroup3 /VIM/
- :call clearmatches()
- :if getmatches() == []
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :unlet m1
- :unlet m2
- :unlet m3
- :" --- Check that "setmatches()" restores a list of matches saved by
- :" --- "getmatches()" without changes. (Matches with equal priority must also
- :" --- remain in the same order.)
- :let @r .= "*** Test 8: "
- :let m1 = matchadd("MyGroup1", "TODO")
- :let m2 = matchadd("MyGroup2", "FIXME", 42)
- :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
- :match MyGroup1 /COFFEE/
- :2match MyGroup2 /HUMPPA/
- :3match MyGroup3 /VIM/
- :let ml = getmatches()
- :call clearmatches()
- :call setmatches(ml)
- :if getmatches() == ml
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :call clearmatches()
- :unlet m1
- :unlet m2
- :unlet m3
- :unlet ml
- :" --- Check that "setmatches()" will not add two matches with the same ID.
The
- :" --- expected behaviour (for now) is to add the first match but not the
- :" --- second and to return 0 (even though it is a matter of debate whether
- :" --- this can be considered successful behaviour).
- :let @r .= "*** Test 9: "
- :let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority':
10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id':
1}])
- :if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10,
'id': 1}] && r1 == 0
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :call clearmatches()
- :unlet r1
- :" --- Check that "setmatches()" returns 0 if successful and otherwise -1.
- :" --- (A range of valid and invalid input values are tried out to generate
the
- :" --- return values.)
- :let @r .= "*** Test 10: "
- :let rs1 = setmatches([])
- :let rs2 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority':
10, 'id': 1}])
- :call clearmatches()
- :let rf1 = setmatches(0)
- :let rf2 = setmatches([0])
- :let rf3 = setmatches([{'wrong key': 'wrong value'}])
- :if rs1 == 0 && rs2 == 0 && rf1 == -1 && rf2 == -1 && rf3 == -1
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED\n"
- :endif
- :unlet rs1
- :unlet rs2
- :unlet rf1
- :unlet rf2
- :unlet rf3
- :" --- Check that "matchaddpos()" positions matches correctly
- :let @r .= "*** Test 11:\n"
- :set nolazyredraw
- :call setline(1, 'abcdefghijklmnopq')
- :call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3)
- :1
- :redraw!
- :let v1 = screenattr(1, 1)
- :let v5 = screenattr(1, 5)
- :let v6 = screenattr(1, 6)
- :let v8 = screenattr(1, 8)
- :let v10 = screenattr(1, 10)
- :let v11 = screenattr(1, 11)
- :let @r .= string(getmatches())."\n"
- :if v1 != v5 && v6 == v1 && v8 == v5 && v10 == v5 && v11 == v1
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED: " . v5 . "/" . v6 . "/" . v8 . "/" . v10 . "/" . v11 .
"\n"
- :endif
- :call clearmatches()
- :"
- :call setline(1, 'abcdΣabcdef')
- :call matchaddpos("MyGroup1", [[1, 4, 2], [1, 9, 2]])
- :1
- :redraw!
- :let v1 = screenattr(1, 1)
- :let v4 = screenattr(1, 4)
- :let v5 = screenattr(1, 5)
- :let v6 = screenattr(1, 6)
- :let v7 = screenattr(1, 7)
- :let v8 = screenattr(1, 8)
- :let v9 = screenattr(1, 9)
- :let v10 = screenattr(1, 10)
- :let @r .= string(getmatches())."\n"
- :if v1 != v4 && v5 == v4 && v6 == v1 && v7 == v1 && v8 == v4 && v9 == v4 &&
v10 == v1
- : let @r .= "OK\n"
- :else
- : let @r .= "FAILED: " . v4 . "/" . v5 . "/" . v6 . "/" . v7 . "/" . v8 .
"/" . v9 . "/" . v10 . "\n"
- :endif
- :" Check, that setmatches() can correctly restore the matches from
matchaddpos()
- :call matchadd('MyGroup1', '\%2lmatchadd')
- :let m=getmatches()
- :call clearmatches()
- :call setmatches(m)
- :let @r .= string(getmatches())."\n"
- G"rp
- :/^Results/,$wq! test.out
- ENDTEST
-
- Results of test63:
--- 0 ----
*** ../vim-7.4.2162/src/testdir/test63.ok 2015-06-19 16:32:52.328116933
+0200
--- src/testdir/test63.ok 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,17 ****
- Results of test63:
- *** Test 1: OK
- *** Test 2: OK
- *** Test 3: OK
- *** Test 4: OK
- *** Test 5: OK
- *** Test 6: OK
- *** Test 7: OK
- *** Test 8: OK
- *** Test 9: OK
- *** Test 10: OK
- *** Test 11:
- [{'group': 'MyGroup1', 'id': 3, 'priority': 10, 'pos1': [1, 5, 1], 'pos2':
[1, 8, 3]}]
- OK
- [{'group': 'MyGroup1', 'id': 11, 'priority': 10, 'pos1': [1, 4, 2], 'pos2':
[1, 9, 2]}]
- OK
- [{'group': 'MyGroup1', 'id': 11, 'priority': 10, 'pos1': [1, 4, 2], 'pos2':
[1, 9, 2]}, {'group': 'MyGroup1', 'pattern': '\%2lmatchadd', 'priority': 10,
'id': 12}]
--- 0 ----
*** ../vim-7.4.2162/src/testdir/test_alot.vim 2016-07-29 16:15:13.038677979
+0200
--- src/testdir/test_alot.vim 2016-08-06 14:57:01.053232619 +0200
***************
*** 21,27 ****
source test_jumps.vim
source test_lambda.vim
source test_lispwords.vim
! source test_matchstrpos.vim
source test_menu.vim
source test_messages.vim
source test_partial.vim
--- 21,27 ----
source test_jumps.vim
source test_lambda.vim
source test_lispwords.vim
! source test_match.vim
source test_menu.vim
source test_messages.vim
source test_partial.vim
*** ../vim-7.4.2162/src/testdir/test_match.vim 2016-08-06 15:28:17.593957595
+0200
--- src/testdir/test_match.vim 2016-08-06 14:57:01.053232619 +0200
***************
*** 0 ****
--- 1,165 ----
+ " Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
+ " matchaddpos(), matcharg(), matchdelete(), matchstrpos() and setmatches().
+
+ function Test_matcharg()
+ highlight MyGroup1 term=bold ctermbg=red guibg=red
+ highlight MyGroup2 term=italic ctermbg=green guibg=green
+ highlight MyGroup3 term=underline ctermbg=blue guibg=blue
+
+ " --- Check that "matcharg()" returns the correct group and pattern if a
match
+ " --- is defined.
+ match MyGroup1 /TODO/
+ 2match MyGroup2 /FIXME/
+ 3match MyGroup3 /XXX/
+ call assert_equal(['MyGroup1', 'TODO'], matcharg(1))
+ call assert_equal(['MyGroup2', 'FIXME'], matcharg(2))
+ call assert_equal(['MyGroup3', 'XXX'], matcharg(3))
+
+ " --- Check that "matcharg()" returns an empty list if the argument is not
1,
+ " --- 2 or 3 (only 0 and 4 are tested).
+ call assert_equal([], matcharg(0))
+ call assert_equal([], matcharg(4))
+
+ " --- Check that "matcharg()" returns ['', ''] if a match is not defined.
+ match
+ 2match
+ 3match
+ call assert_equal(['', ''], matcharg(1))
+ call assert_equal(['', ''], matcharg(2))
+ call assert_equal(['', ''], matcharg(3))
+
+ " --- Check that "matchadd()" and "getmatches()" agree on added matches and
+ " --- that default values apply.
+ let m1 = matchadd("MyGroup1", "TODO")
+ let m2 = matchadd("MyGroup2", "FIXME", 42)
+ let m3 = matchadd("MyGroup3", "XXX", 60, 17)
+ let ans = [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id':
4},
+ \ {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id':
5},
+ \ {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id':
17}]
+ call assert_equal(ans, getmatches())
+
+ " --- Check that "matchdelete()" deletes the matches defined in the previous
+ " --- test correctly.
+ call matchdelete(m1)
+ call matchdelete(m2)
+ call matchdelete(m3)
+ call assert_equal([], getmatches())
+
+ " --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
+ let m = matchadd("MyGroup1", "TODO")
+ call assert_equal(0, matchdelete(m))
+ call assert_fails('call matchdelete(42)', 'E803:')
+
+ " --- Check that "clearmatches()" clears all matches defined by ":match" and
+ " --- "matchadd()".
+ let m1 = matchadd("MyGroup1", "TODO")
+ let m2 = matchadd("MyGroup2", "FIXME", 42)
+ let m3 = matchadd("MyGroup3", "XXX", 60, 17)
+ match MyGroup1 /COFFEE/
+ 2match MyGroup2 /HUMPPA/
+ 3match MyGroup3 /VIM/
+ call clearmatches()
+ call assert_equal([], getmatches())
+
+ " --- Check that "setmatches()" restores a list of matches saved by
+ " --- "getmatches()" without changes. (Matches with equal priority must also
+ " --- remain in the same order.)
+ let m1 = matchadd("MyGroup1", "TODO")
+ let m2 = matchadd("MyGroup2", "FIXME", 42)
+ let m3 = matchadd("MyGroup3", "XXX", 60, 17)
+ match MyGroup1 /COFFEE/
+ 2match MyGroup2 /HUMPPA/
+ 3match MyGroup3 /VIM/
+ let ml = getmatches()
+ call clearmatches()
+ call setmatches(ml)
+ call assert_equal(ml, getmatches())
+ call clearmatches()
+
+ " --- Check that "setmatches()" will not add two matches with the same ID.
The
+ " --- expected behaviour (for now) is to add the first match but not the
+ " --- second and to return 0 (even though it is a matter of debate whether
+ " --- this can be considered successful behaviour).
+ let data = [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id':
1},
+ \ {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id':
1}]
+ call assert_fails('call setmatches(data)', 'E801:')
+ call assert_equal([data[0]], getmatches())
+ call clearmatches()
+
+ " --- Check that "setmatches()" returns 0 if successful and otherwise -1.
+ " --- (A range of valid and invalid input values are tried out to generate
the
+ " --- return values.)
+ call assert_equal(0, setmatches([]))
+ call assert_equal(0, setmatches([{'group': 'MyGroup1', 'pattern': 'TODO',
'priority': 10, 'id': 1}]))
+ call clearmatches()
+ call assert_fails('call setmatches(0)', 'E714:')
+ call assert_fails('call setmatches([0])', 'E474:')
+ call assert_fails("call setmatches([{'wrong key': 'wrong value'}])",
'E474:')
+
+ call setline(1, 'abcdefghijklmnopq')
+ call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3)
+ 1
+ redraw!
+ let v1 = screenattr(1, 1)
+ let v5 = screenattr(1, 5)
+ let v6 = screenattr(1, 6)
+ let v8 = screenattr(1, 8)
+ let v10 = screenattr(1, 10)
+ let v11 = screenattr(1, 11)
+ call assert_notequal(v1, v5)
+ call assert_equal(v6, v1)
+ call assert_equal(v8, v5)
+ call assert_equal(v10, v5)
+ call assert_equal(v11, v1)
+ call assert_equal([{'group': 'MyGroup1', 'id': 3, 'priority': 10, 'pos1':
[1, 5, 1], 'pos2': [1, 8, 3]}], getmatches())
+ call clearmatches()
+
+ "
+ if has('multi_byte')
+ call setline(1, 'abcdΣabcdef')
+ call matchaddpos("MyGroup1", [[1, 4, 2], [1, 9, 2]])
+ 1
+ redraw!
+ let v1 = screenattr(1, 1)
+ let v4 = screenattr(1, 4)
+ let v5 = screenattr(1, 5)
+ let v6 = screenattr(1, 6)
+ let v7 = screenattr(1, 7)
+ let v8 = screenattr(1, 8)
+ let v9 = screenattr(1, 9)
+ let v10 = screenattr(1, 10)
+ call assert_equal([{'group': 'MyGroup1', 'id': 11, 'priority': 10,
'pos1': [1, 4, 2], 'pos2': [1, 9, 2]}], getmatches())
+ call assert_notequal(v1, v4)
+ call assert_equal(v5, v4)
+ call assert_equal(v6, v1)
+ call assert_equal(v7, v1)
+ call assert_equal(v8, v4)
+ call assert_equal(v9, v4)
+ call assert_equal(v10, v1)
+
+ " Check, that setmatches() can correctly restore the matches from
matchaddpos()
+ call matchadd('MyGroup1', '\%2lmatchadd')
+ let m=getmatches()
+ call clearmatches()
+ call setmatches(m)
+ call assert_equal([{'group': 'MyGroup1', 'id': 11, 'priority': 10,
'pos1': [1, 4, 2], 'pos2': [1,9, 2]}, {'group': 'MyGroup1', 'pattern':
'\%2lmatchadd', 'priority': 10, 'id': 12}], getmatches())
+ endif
+
+ highlight MyGroup1 NONE
+ highlight MyGroup2 NONE
+ highlight MyGroup3 NONE
+ endfunc
+
+ func Test_matchstrpos()
+ call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
+
+ call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
+
+ call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
+
+ call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing',
'execute'], 'ing'))
+
+ call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing',
'execute'], 'img'))
+ endfunc
+
+ " vim: et ts=2 sw=2
*** ../vim-7.4.2162/src/testdir/test_matchstrpos.vim 2016-03-29
23:10:14.014448074 +0200
--- src/testdir/test_matchstrpos.vim 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,13 ****
- " Test matchstrpos
-
- func Test_matchstrpos()
- call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
-
- call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
-
- call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
-
- call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing',
'execute'], 'ing'))
-
- call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing',
'execute'], 'img'))
- endfunc
--- 0 ----
*** ../vim-7.4.2162/src/version.c 2016-08-06 14:12:44.954591453 +0200
--- src/version.c 2016-08-06 15:28:26.993880375 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2163,
/**/
--
Eye have a spelling checker, it came with my PC;
It plainly marks four my revue mistakes I cannot sea.
I've run this poem threw it, I'm sure your please to no,
It's letter perfect in it's weigh, my checker tolled me sew!
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.