test(old): run some part of 'cpoptions' tests

This commit is contained in:
zeertzjq 2023-02-17 08:14:24 +08:00
parent 0326ef2f41
commit dea311b33d
3 changed files with 101 additions and 98 deletions

View File

@ -217,33 +217,33 @@ endfunc
" Test for the 'g' flag in 'cpo' (jump to line 1 when re-editing a file) " Test for the 'g' flag in 'cpo' (jump to line 1 when re-editing a file)
func Test_cpo_g() func Test_cpo_g()
throw 'Skipped: Nvim does not support cpoptions flag "g"'
let save_cpo = &cpo let save_cpo = &cpo
new test_cpoptions.vim new test_cpoptions.vim
set cpo-=g set cpo-=g
normal 20G normal 20G
edit edit
call assert_equal(20, line('.')) call assert_equal(20, line('.'))
set cpo+=g " Nvim: no "g" flag in 'cpoptions'.
edit " set cpo+=g
call assert_equal(1, line('.')) " edit
" call assert_equal(1, line('.'))
close! close!
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
" Test for inserting text in a line with only spaces ('H' flag in 'cpoptions') " Test for inserting text in a line with only spaces ('H' flag in 'cpoptions')
func Test_cpo_H() func Test_cpo_H()
throw 'Skipped: Nvim does not support cpoptions flag "H"'
let save_cpo = &cpo let save_cpo = &cpo
new new
set cpo-=H set cpo-=H
call setline(1, ' ') call setline(1, ' ')
normal! Ia normal! Ia
call assert_equal(' a', getline(1)) call assert_equal(' a', getline(1))
set cpo+=H " Nvim: no "H" flag in 'cpoptions'.
call setline(1, ' ') " set cpo+=H
normal! Ia " call setline(1, ' ')
call assert_equal(' a ', getline(1)) " normal! Ia
" call assert_equal(' a ', getline(1))
close! close!
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -560,15 +560,15 @@ endfunc
" Test for the 'w' flag in 'cpo' ('cw' on a blank character changes only one " Test for the 'w' flag in 'cpo' ('cw' on a blank character changes only one
" character) " character)
func Test_cpo_w() func Test_cpo_w()
throw 'Skipped: Nvim does not support cpoptions flag "w"'
let save_cpo = &cpo let save_cpo = &cpo
new new
set cpo+=w " Nvim: no "w" flag in 'cpoptions'.
call setline(1, 'here are some words') " set cpo+=w
norm! 1gg0elcwZZZ " call setline(1, 'here are some words')
call assert_equal('hereZZZ are some words', getline('.')) " norm! 1gg0elcwZZZ
norm! 1gg2elcWYYY " call assert_equal('hereZZZ are some words', getline('.'))
call assert_equal('hereZZZ areYYY some words', getline('.')) " norm! 1gg2elcWYYY
" call assert_equal('hereZZZ areYYY some words', getline('.'))
set cpo-=w set cpo-=w
call setline(1, 'here are some words') call setline(1, 'here are some words')
norm! 1gg0elcwZZZ norm! 1gg0elcwZZZ
@ -745,16 +745,16 @@ endfunc
" Test for the '*' flag in 'cpo' (':*' is same as ':@') " Test for the '*' flag in 'cpo' (':*' is same as ':@')
func Test_cpo_star() func Test_cpo_star()
throw 'Skipped: Nvim does not support cpoptions flag "*"'
let save_cpo = &cpo let save_cpo = &cpo
let x = 0 let x = 0
new new
set cpo-=* set cpo-=*
let @a = 'let x += 1' let @a = 'let x += 1'
call assert_fails('*a', 'E20:') call assert_fails('*a', 'E20:')
set cpo+=* " Nvim: no "*" flag in 'cpoptions'.
*a " set cpo+=*
call assert_equal(1, x) " *a
" call assert_equal(1, x)
close! close!
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -815,7 +815,6 @@ endfunc
" Test for the '#' flag in 'cpo' (count before 'D', 'o' and 'O' operators) " Test for the '#' flag in 'cpo' (count before 'D', 'o' and 'O' operators)
func Test_cpo_hash() func Test_cpo_hash()
throw 'Skipped: Nvim does not support cpoptions flag "#"'
let save_cpo = &cpo let save_cpo = &cpo
new new
set cpo-=# set cpo-=#
@ -827,14 +826,15 @@ func Test_cpo_hash()
normal gg2Otwo normal gg2Otwo
call assert_equal(['two', 'two', 'three', 'four', 'four'], getline(1, '$')) call assert_equal(['two', 'two', 'three', 'four', 'four'], getline(1, '$'))
%d %d
set cpo+=# " Nvim: no "#" flag in 'cpoptions'.
call setline(1, ['one', 'two', 'three']) " set cpo+=#
normal gg2D " call setline(1, ['one', 'two', 'three'])
call assert_equal(['', 'two', 'three'], getline(1, '$')) " normal gg2D
normal gg2oone " call assert_equal(['', 'two', 'three'], getline(1, '$'))
call assert_equal(['', 'one', 'two', 'three'], getline(1, '$')) " normal gg2oone
normal gg2Ozero " call assert_equal(['', 'one', 'two', 'three'], getline(1, '$'))
call assert_equal(['zero', '', 'one', 'two', 'three'], getline(1, '$')) " normal gg2Ozero
" call assert_equal(['zero', '', 'one', 'two', 'three'], getline(1, '$'))
close! close!
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -858,16 +858,16 @@ endfunc
" Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern) " Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern)
func Test_cpo_backslash() func Test_cpo_backslash()
throw 'Skipped: Nvim does not support cpoptions flag "\"'
let save_cpo = &cpo let save_cpo = &cpo
new new
call setline(1, ['', " \\-string"]) call setline(1, ['', " \\-string"])
set cpo-=\ set cpo-=\
exe 'normal gg/[ \-]' .. "\<CR>n" exe 'normal gg/[ \-]' .. "\<CR>n"
call assert_equal(3, col('.')) call assert_equal(3, col('.'))
set cpo+=\ " Nvim: no "\" flag in 'cpoptions'.
exe 'normal gg/[ \-]' .. "\<CR>n" " set cpo+=\
call assert_equal(2, col('.')) " exe 'normal gg/[ \-]' .. "\<CR>n"
" call assert_equal(2, col('.'))
close! close!
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -877,7 +877,6 @@ endfunc
" Test for the '{' flag in 'cpo' (the "{" and "}" commands stop at a { " Test for the '{' flag in 'cpo' (the "{" and "}" commands stop at a {
" character at the start of a line) " character at the start of a line)
func Test_cpo_brace() func Test_cpo_brace()
throw 'Skipped: Nvim does not support cpoptions flag "{"'
let save_cpo = &cpo let save_cpo = &cpo
new new
call setline(1, ['', '{', ' int i;', '}', '']) call setline(1, ['', '{', ' int i;', '}', ''])
@ -886,11 +885,12 @@ func Test_cpo_brace()
call assert_equal(5, line('.')) call assert_equal(5, line('.'))
normal G{ normal G{
call assert_equal(1, line('.')) call assert_equal(1, line('.'))
set cpo+={ " Nvim: no "{" flag in 'cpoptions'.
normal gg} " set cpo+={
call assert_equal(2, line('.')) " normal gg}
normal G{ " call assert_equal(2, line('.'))
call assert_equal(2, line('.')) " normal G{
" call assert_equal(2, line('.'))
close! close!
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc

View File

@ -2254,61 +2254,63 @@ func Test_normal29_brace()
" set cpo+={ " set cpo+={
" 1 " 1
" norm! 0d2} " norm! 0d2}
" let expected =<< trim [DATA]
" { let expected =<< trim [DATA]
" This is no paragraph {
" unless the '{' is set This is no paragraph
" in 'cpoptions' unless the '{' is set
" } in 'cpoptions'
" .IP }
" The nroff macros IP separates a paragraph .IP
" That means, it must be a '.' The nroff macros IP separates a paragraph
" followed by IP That means, it must be a '.'
" .LPIt does not matter, if afterwards some followed by IP
" more characters follow. .LPIt does not matter, if afterwards some
" .SHAlso section boundaries from the nroff more characters follow.
" macros terminate a paragraph. That means .SHAlso section boundaries from the nroff
" a character like this: macros terminate a paragraph. That means
" .NH a character like this:
" End of text here .NH
" End of text here
" [DATA]
[DATA]
" call assert_equal(expected, getline(1, '$')) " call assert_equal(expected, getline(1, '$'))
"
" $ " $
" norm! d} " norm! d}
" let expected =<< trim [DATA]
" { let expected =<< trim [DATA]
" This is no paragraph {
" unless the '{' is set This is no paragraph
" in 'cpoptions' unless the '{' is set
" } in 'cpoptions'
" .IP }
" The nroff macros IP separates a paragraph .IP
" That means, it must be a '.' The nroff macros IP separates a paragraph
" followed by IP That means, it must be a '.'
" .LPIt does not matter, if afterwards some followed by IP
" more characters follow. .LPIt does not matter, if afterwards some
" .SHAlso section boundaries from the nroff more characters follow.
" macros terminate a paragraph. That means .SHAlso section boundaries from the nroff
" a character like this: macros terminate a paragraph. That means
" .NH a character like this:
" End of text here .NH
" End of text here
" [DATA]
[DATA]
" call assert_equal(expected, getline(1, '$')) " call assert_equal(expected, getline(1, '$'))
"
" norm! gg} " norm! gg}
" norm! d5} " norm! d5}
"
" let expected =<< trim [DATA]
" {
" This is no paragraph
" unless the '{' is set
" in 'cpoptions'
" }
" [DATA] let expected =<< trim [DATA]
{
This is no paragraph
unless the '{' is set
in 'cpoptions'
}
[DATA]
" call assert_equal(expected, getline(1, '$')) " call assert_equal(expected, getline(1, '$'))
" Jumping to a fold should open the fold " Jumping to a fold should open the fold

View File

@ -296,15 +296,15 @@ endfunc
" Test for *:s%* on :substitute. " Test for *:s%* on :substitute.
func Test_sub_cmd_6() func Test_sub_cmd_6()
throw 'Skipped: Nvim does not support cpoptions flag "/"'
set magic& set magic&
set cpo+=/ " Nvim: no "/" flag in 'cpoptions'.
" set cpo+=/
" List entry format: [input, cmd, output] " List entry format: [input, cmd, output]
let tests = [ ['A', 's/A/a/', ['a']], let tests = [ ['A', 's/A/a/', ['a']],
\ ['B', 's/B/%/', ['a']], \ ['B', 's/B/%/', ['a']],
\ ] \ ]
call Run_SubCmd_Tests(tests) " call Run_SubCmd_Tests(tests)
set cpo-=/ set cpo-=/
let tests = [ ['C', 's/C/c/', ['c']], let tests = [ ['C', 's/C/c/', ['c']],
@ -585,10 +585,11 @@ endfunc
func Test_sub_replace_6() func Test_sub_replace_6()
set magic& set magic&
" Nvim: no "/" flag in 'cpoptions'.
" set cpo+=/ " set cpo+=/
call assert_equal('a', substitute('A', 'A', 'a', '')) call assert_equal('a', substitute('A', 'A', 'a', ''))
call assert_equal('%', substitute('B', 'B', '%', '')) call assert_equal('%', substitute('B', 'B', '%', ''))
" set cpo-=/ set cpo-=/
call assert_equal('c', substitute('C', 'C', 'c', '')) call assert_equal('c', substitute('C', 'C', 'c', ''))
call assert_equal('%', substitute('D', 'D', '%', '')) call assert_equal('%', substitute('D', 'D', '%', ''))
endfunc endfunc
@ -853,13 +854,13 @@ func Test_sub_with_no_last_pat()
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
" Nvim does not support cpoptions flag "/"' let lines =<< trim [SCRIPT]
" let lines =<< trim [SCRIPT] set cpo+=/
" set cpo+=/ call assert_fails('s/abc/%/', 'E33:')
" call assert_fails('s/abc/%/', 'E33:') call writefile(v:errors, 'Xresult')
" call writefile(v:errors, 'Xresult') qall!
" qall! [SCRIPT]
" [SCRIPT] " Nvim: no "/" flag in 'cpoptions'.
" call writefile(lines, 'Xscript') " call writefile(lines, 'Xscript')
" if RunVim([], [], '--clean -S Xscript') " if RunVim([], [], '--clean -S Xscript')
" call assert_equal([], readfile('Xresult')) " call assert_equal([], readfile('Xresult'))