forked from aniani/vim
patch 8.0.1158: still old style tests
Problem: Still old style tests. Solution: Convert serveral tests to new style. (Yegappan Lakshmanan)
This commit is contained in:
@@ -52,3 +52,104 @@ func Test_quote_selection_selection_exclusive()
|
||||
set selection&vim
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Tests for string and html text objects
|
||||
func Test_string_html_objects()
|
||||
enew!
|
||||
|
||||
let t = '"wo\"rd\\" foo'
|
||||
put =t
|
||||
normal! da"
|
||||
call assert_equal('foo', getline('.'))
|
||||
|
||||
let t = "'foo' 'bar' 'piep'"
|
||||
put =t
|
||||
normal! 0va'a'rx
|
||||
call assert_equal("xxxxxxxxxxxx'piep'", getline('.'))
|
||||
|
||||
let t = "bla bla `quote` blah"
|
||||
put =t
|
||||
normal! 02f`da`
|
||||
call assert_equal("bla bla blah", getline('.'))
|
||||
|
||||
let t = 'out " in "noXno"'
|
||||
put =t
|
||||
normal! 0fXdi"
|
||||
call assert_equal('out " in ""', getline('.'))
|
||||
|
||||
let t = "\"'\" 'blah' rep 'buh'"
|
||||
put =t
|
||||
normal! 03f'vi'ry
|
||||
call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.'))
|
||||
|
||||
set quoteescape=+*-
|
||||
let t = "bla `s*`d-`+++`l**` b`la"
|
||||
put =t
|
||||
normal! di`
|
||||
call assert_equal("bla `` b`la", getline('.'))
|
||||
|
||||
let t = 'voo "nah" sdf " asdf" sdf " sdf" sd'
|
||||
put =t
|
||||
normal! $F"va"oha"i"rz
|
||||
call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.'))
|
||||
|
||||
let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
|
||||
put =t
|
||||
normal! fXdit
|
||||
call assert_equal('-<b>asdf<i></i>asdf</b>-', getline('.'))
|
||||
|
||||
let t = "-<b>asdX<i>a<i />sdf</i>asdf</b>-"
|
||||
put =t
|
||||
normal! 0fXdit
|
||||
call assert_equal('-<b></b>-', getline('.'))
|
||||
|
||||
let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
|
||||
put =t
|
||||
normal! fXdat
|
||||
call assert_equal('-<b>asdfasdf</b>-', getline('.'))
|
||||
|
||||
let t = "-<b>asdX<i>as<b />df</i>asdf</b>-"
|
||||
put =t
|
||||
normal! 0fXdat
|
||||
call assert_equal('--', getline('.'))
|
||||
|
||||
let t = "-<b>\ninnertext object\n</b>"
|
||||
put =t
|
||||
normal! dit
|
||||
call assert_equal('-<b></b>', getline('.'))
|
||||
|
||||
set quoteescape&
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
" Tests for match() and matchstr()
|
||||
func Test_match()
|
||||
call assert_equal("b", matchstr("abcd", ".", 0, 2))
|
||||
call assert_equal("bc", matchstr("abcd", "..", 0, 2))
|
||||
call assert_equal("c", matchstr("abcd", ".", 2, 0))
|
||||
call assert_equal("a", matchstr("abcd", ".", 0, -1))
|
||||
call assert_equal(-1, match("abcd", ".", 0, 5))
|
||||
call assert_equal(0 , match("abcd", ".", 0, -1))
|
||||
call assert_equal(0 , match('abc', '.', 0, 1))
|
||||
call assert_equal(1 , match('abc', '.', 0, 2))
|
||||
call assert_equal(2 , match('abc', '.', 0, 3))
|
||||
call assert_equal(-1, match('abc', '.', 0, 4))
|
||||
call assert_equal(1 , match('abc', '.', 1, 1))
|
||||
call assert_equal(2 , match('abc', '.', 2, 1))
|
||||
call assert_equal(-1, match('abc', '.', 3, 1))
|
||||
call assert_equal(3 , match('abc', '$', 0, 1))
|
||||
call assert_equal(-1, match('abc', '$', 0, 2))
|
||||
call assert_equal(3 , match('abc', '$', 1, 1))
|
||||
call assert_equal(3 , match('abc', '$', 2, 1))
|
||||
call assert_equal(3 , match('abc', '$', 3, 1))
|
||||
call assert_equal(-1, match('abc', '$', 4, 1))
|
||||
call assert_equal(0 , match('abc', '\zs', 0, 1))
|
||||
call assert_equal(1 , match('abc', '\zs', 0, 2))
|
||||
call assert_equal(2 , match('abc', '\zs', 0, 3))
|
||||
call assert_equal(3 , match('abc', '\zs', 0, 4))
|
||||
call assert_equal(-1, match('abc', '\zs', 0, 5))
|
||||
call assert_equal(1 , match('abc', '\zs', 1, 1))
|
||||
call assert_equal(2 , match('abc', '\zs', 2, 1))
|
||||
call assert_equal(3 , match('abc', '\zs', 3, 1))
|
||||
call assert_equal(-1, match('abc', '\zs', 4, 1))
|
||||
endfunc
|
||||
|
||||
Reference in New Issue
Block a user