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

View File

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

View File

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