" Test for cinoptions and cindent
-func Test_cino_hash()
- " Test that curbuf->b_ind_hash_comment is correctly reset
+def Test_cino_hash()
+ # Test that curbuf->b_ind_hash_comment is correctly reset
new
setlocal cindent cinoptions=#1
setlocal cinoptions=
- call setline(1, ["#include <iostream>"])
- call cursor(1, 1)
+ setline(1, ["#include <iostream>"])
+ cursor(1, 1)
norm! o#include
- "call feedkeys("o#include\<esc>", 't')
- call assert_equal(["#include <iostream>", "#include"], getline(1,2))
+ assert_equal(["#include <iostream>", "#include"], getline(1, 2))
+
bwipe!
-endfunc
+enddef
-func Test_cino_extern_c()
- " Test for cino-E
+def Test_cino_extern_c()
+ # Test for cino-E
- let without_ind =<< trim [CODE]
+ var without_ind =<< trim [CODE]
#ifdef __cplusplus
extern "C" {
#endif
#endif
[CODE]
- let with_ind =<< trim [CODE]
+ var with_ind =<< trim [CODE]
#ifdef __cplusplus
extern "C" {
#endif
[CODE]
new
setlocal cindent cinoptions=E0
- call setline(1, without_ind)
- call feedkeys("gg=G", 'tx')
- call assert_equal(with_ind, getline(1, '$'))
+ setline(1, without_ind)
+ feedkeys("gg=G", 'tx')
+ assert_equal(with_ind, getline(1, '$'))
setlocal cinoptions=E-s
- call setline(1, with_ind)
- call feedkeys("gg=G", 'tx')
- call assert_equal(without_ind, getline(1, '$'))
+ setline(1, with_ind)
+ feedkeys("gg=G", 'tx')
+ assert_equal(without_ind, getline(1, '$'))
setlocal cinoptions=Es
- let tests = [
+ var tests = [
\ ['recognized', ['extern "C" {'], "\t\t;"],
\ ['recognized', ['extern "C++" {'], "\t\t;"],
\ ['recognized', ['extern /* com */ "C"{'], "\t\t;"],
\ ]
for pair in tests
- let lines = pair[1]
- call setline(1, lines)
- call feedkeys(len(lines) . "Go;", 'tx')
- call assert_equal(pair[2], getline(len(lines) + 1), 'Failed for "' . string(lines) . '"')
+ var lines = pair[1]
+ setline(1, lines)
+ feedkeys(len(lines) .. "Go;", 'tx')
+ assert_equal(pair[2], getline(len(lines) + 1),
+ 'Failed for "' .. string(lines) .. '"')
endfor
bwipe!
-endfunc
+enddef
-func Test_cindent_rawstring()
+def Test_cindent_rawstring()
new
setl cindent
- call feedkeys("i" .
- \ "int main() {\<CR>" .
- \ "R\"(\<CR>" .
- \ ")\";\<CR>" .
+ feedkeys("i" ..
+ \ "int main() {\<CR>" ..
+ \ "R\"(\<CR>" ..
+ \ ")\";\<CR>" ..
\ "statement;\<Esc>", "x")
- call assert_equal("\tstatement;", getline(line('.')))
- bw!
-endfunc
+ assert_equal("\tstatement;", getline(line('.')))
+
+ bwipe!
+enddef
-func Test_cindent_expr()
+def Test_cindent_expr()
new
- func! MyIndentFunction()
+ def g:MyIndentFunction(): number
return v:lnum == 1 ? shiftwidth() : 0
- endfunc
- setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction()
- let testinput =<< trim [CODE]
+ enddef
+ setl expandtab sw=8 indentkeys+=; indentexpr=g:MyIndentFunction()
+ var testinput =<< trim [CODE]
var_a = something()
b = something()
[CODE]
- call setline(1, testinput)
- call cursor(1, 1)
- call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
- let expected =<< [CODE]
+ setline(1, testinput)
+ cursor(1, 1)
+ feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
+ var expected =<< [CODE]
var_a = something();
b = something();
[CODE]
- call assert_equal(expected, getline(1, '$'))
+ assert_equal(expected, getline(1, '$'))
- %d
- let testinput =<< [CODE]
+ :%d
+ testinput =<< [CODE]
var_a = something()
b = something()
[CODE]
- call setline(1, testinput)
- call cursor(1, 1)
- call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
- let expected =<< [CODE]
+ setline(1, testinput)
+ cursor(1, 1)
+ feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
+ expected =<< [CODE]
var_a = something();
b = something()
[CODE]
- call assert_equal(expected, getline(1, '$'))
- bw!
-endfunc
+ assert_equal(expected, getline(1, '$'))
-func Test_cindent_func()
+ delfunc g:MyIndentFunction
+
+ bwipe!
+enddef
+
+def Test_cindent_func()
new
setlocal cindent
- call setline(1, ['int main(void)', '{', 'return 0;', '}'])
- call assert_equal(-1, cindent(0))
- call assert_equal(&sw, 3->cindent())
- call assert_equal(-1, cindent(line('$')+1))
+ setline(1, ['int main(void)', '{', 'return 0;', '}'])
+ assert_equal(-1, cindent(0))
+ assert_equal(&sw, 3->cindent())
+ assert_equal(-1, cindent(line('$') + 1))
+
bwipe!
-endfunc
+enddef
-func Test_cindent_1()
+def Test_cindent_1()
new
setl cindent ts=4 sw=4
setl cino& sts&
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
/* start of AUTO matically checked vim: set ts=4 : */
{
if (test)
/* end of AUTO */
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('start of AUTO')
+ search('start of AUTO')
exe "normal =/end of AUTO\<CR>"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
/* start of AUTO matically checked vim: set ts=4 : */
{
if (test)
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
+
+ bwipe!
+enddef
-func Test_cindent_2()
+def Test_cindent_2()
new
setl cindent ts=4 sw=4
setl tw=0 noai fo=croq
- let &wm = &columns - 20
+ &wm = &columns - 20
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
/* this is
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('serious', 'e')
+ search('serious', 'e')
normal a about life, the universe, and the rest
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
/* this is
[CODE]
- call assert_equal(expected, getline(1, '$'))
+ assert_equal(expected, getline(1, '$'))
set wm&
- enew! | close
-endfunc
-func Test_cindent_3()
+ bwipe!
+enddef
+
+def Test_cindent_3()
new
setl nocindent ts=4 sw=4
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
/*
* Testing for comments, without 'cin' set
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('comments')
+ search('comments')
normal joabout life
- call search('happens')
+ search('happens')
normal jothere
- call search('below')
+ search('below')
normal oline
- call search('this')
+ search('this')
normal Ohello
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
/*
* Testing for comments, without 'cin' set
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
+
+ bwipe!
+enddef
-func Test_cindent_4()
+def Test_cindent_4()
new
setl cindent ts=4 sw=4
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
var = this + that + vec[0] * vec[0]
+ vec[1] * vec[1]
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('vec2')
+ search('vec2')
normal ==
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
var = this + that + vec[0] * vec[0]
+ vec[1] * vec[1]
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
-func Test_cindent_5()
+ bwipe!
+enddef
+
+def Test_cindent_5()
new
setl cindent ts=4 sw=4
setl cino=}4
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
asdf asdflkajds f;
if (tes & ting) {
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('testing1')
+ search('testing1')
exe "normal k2==/testing2\<CR>"
normal k2==
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
asdf asdflkajds f;
if (tes & ting) {
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
-func Test_cindent_6()
+ bwipe!
+enddef
+
+def Test_cindent_6()
new
setl cindent ts=4 sw=4
setl cino=(0,)20
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
main ( int first_par, /*
* Comment for
* first par
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('main')
+ search('main')
normal =][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
main ( int first_par, /*
* Comment for
* first par
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
-func Test_cindent_7()
+ bwipe!
+enddef
+
+def Test_cindent_7()
new
setl cindent ts=4 sw=4
setl cino=es,n0s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
main(void)
{
/* Make sure that cino=X0s is not parsed like cino=Xs. */
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('main')
+ search('main')
normal =][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
main(void)
{
/* Make sure that cino=X0s is not parsed like cino=Xs. */
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_8()
+def Test_cindent_8()
new
setl cindent ts=4 sw=4
setl cino=
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
do
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
do
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
-func Test_cindent_9()
+ bwipe!
+enddef
+
+def Test_cindent_9()
new
setl cindent ts=4 sw=4
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
+
+ bwipe!
+enddef
-func Test_cindent_10()
+def Test_cindent_10()
new
setl cindent ts=4 sw=4
setl cino={s,e-s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
[CODE]
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ assert_equal(expected, getline(1, '$'))
-func Test_cindent_11()
+ bwipe!
+enddef
+
+def Test_cindent_11()
new
setl cindent ts=4 sw=4
setl cino={s,fs
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void bar(void)
{
static array[2][2] =
/* foo */
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
exe "normal ]]=/ foo\<CR>"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void bar(void)
{
static array[2][2] =
/* foo */
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_12()
+def Test_cindent_12()
new
setl cindent ts=4 sw=4
setl cino=
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
a()
{
do {
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('while')
+ search('while')
normal ohere
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
a()
{
do {
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_13()
+def Test_cindent_13()
new
setl cindent ts=4 sw=4
setl cino= com=
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
a()
{
label1:
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('comment')
- exe "normal olabel2: b();\rlabel3 /* post */:\r/* pre */ label4:\r" .
- \ "f(/*com*/);\rif (/*com*/)\rcmd();"
+ search('comment')
+ exe "normal olabel2: b();\rlabel3 /* post */:\r/* pre */ label4:\r"
+ .. "f(/*com*/);\rif (/*com*/)\rcmd();"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
a()
{
label1:
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_14()
+def Test_cindent_14()
new
setl cindent ts=4 sw=4
setl comments& comments^=s:/*,m:**,ex:*/
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
/*
* A simple comment
*/
*/
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('simple')
+ search('simple')
normal =5j
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
/*
* A simple comment
*/
*/
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_15()
+def Test_cindent_15()
new
setl cindent ts=4 sw=4
setl cino=c0
setl comments& comments-=s1:/* comments^=s0:/*
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_16()
+def Test_cindent_16()
new
setl cindent ts=4 sw=4
setl cino=c0,C1
setl comments& comments-=s1:/* comments^=s0:/*
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_17()
+def Test_cindent_17()
new
setl cindent ts=4 sw=4
setl cino=
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
c = c1 &&
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
c = c1 &&
}
[CODE]
-
call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
-func Test_cindent_18()
+ bwipe!
+enddef
+
+def Test_cindent_18()
new
setl cindent ts=4 sw=4
setl cino=(s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
c = c1 &&
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
c = c1 &&
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_19()
+def Test_cindent_19()
new
setl cindent ts=4 sw=4
set cino=(s,U1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
c = c1 &&
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
c = c1 &&
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_20()
+def Test_cindent_20()
new
setl cindent ts=4 sw=4
setl cino=(0
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
if ( c1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
if ( c1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_21()
+def Test_cindent_21()
new
setl cindent ts=4 sw=4
setl cino=(0,w1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
if ( c1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
if ( c1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_22()
+def Test_cindent_22()
new
setl cindent ts=4 sw=4
setl cino=(s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
c = c1 && (
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
c = c1 && (
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_23()
+def Test_cindent_23()
new
setl cindent ts=4 sw=4
setl cino=(s,m1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
c = c1 && (
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
c = c1 && (
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_24()
+def Test_cindent_24()
new
setl cindent ts=4 sw=4
setl cino=b1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
switch (x)
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
switch (x)
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_25()
+def Test_cindent_25()
new
setl cindent ts=4 sw=4
setl cino=(0,W5
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
invokeme(
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
invokeme(
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_26()
+def Test_cindent_26()
new
setl cindent ts=4 sw=4
setl cino=/6
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
statement;
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
statement;
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_27()
+def Test_cindent_27()
new
setl cindent ts=4 sw=4
setl cino=
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void f()
{
statement;
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
exe "normal ]]/comment 1/+1\<CR>=="
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void f()
{
statement;
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_28()
+def Test_cindent_28()
new
setl cindent ts=4 sw=4
setl cino=g0
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
class CAbc
{
int Test() { return FALSE; }
};
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
class CAbc
{
int Test() { return FALSE; }
};
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_29()
+def Test_cindent_29()
new
setl cindent ts=4 sw=4
setl cino=(0,gs,hs
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
class Foo : public Bar
{
public:
};
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
class Foo : public Bar
{
public:
};
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_30()
+def Test_cindent_30()
new
setl cindent ts=4 sw=4
setl cino=+20
- let code =<< [CODE]
+ var code =<< [CODE]
void
foo()
{
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< [CODE]
+ var expected =<< [CODE]
void
foo()
{
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_31()
+def Test_cindent_31()
new
setl cindent ts=4 sw=4
setl cino=(0,W2s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_32()
+def Test_cindent_32()
new
setl cindent ts=4 sw=4
setl cino=M1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
int main ()
{
if (cond1 &&
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
int main ()
{
if (cond1 &&
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_33()
+def Test_cindent_33()
new
setl cindent ts=4 sw=4
setl cino=(0,ts
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(int a
#if defined(FOO)
, int b
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal 2j=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(int a
#if defined(FOO)
, int b
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_34()
+def Test_cindent_34()
new
setl cindent ts=4 sw=4
setl cino=(0
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void
func(int a
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal =][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void
func(int a
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_35()
+def Test_cindent_35()
new
setl cindent ts=4 sw=4
setl cino&
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if(x==y)
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=7][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if(x==y)
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_36()
+def Test_cindent_36()
new
setl cindent ts=4 sw=4
setl cino&
setl cino+=l1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
int tab[] =
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
int tab[] =
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_37()
+def Test_cindent_37()
new
setl cindent ts=4 sw=4
setl cino&
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
cout << "a"
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
cout << "a"
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_38()
+def Test_cindent_38()
new
setl cindent ts=4 sw=4
setl com=s1:/*,m:*,ex:*/
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
/*
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]3jofoo();
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
/*
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_39()
+def Test_cindent_39()
new
setl cindent ts=4 sw=4
setl cino&
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
for (int i = 0; i < 10; ++i)
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
for (int i = 0; i < 10; ++i)
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_40()
+def Test_cindent_40()
new
setl cindent ts=4 sw=4
setl cino=k2s,(0
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_41()
+def Test_cindent_41()
new
setl cindent ts=4 sw=4
setl cino=k2s,(s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_42()
+def Test_cindent_42()
new
setl cindent ts=4 sw=4
setl cino=k2s,(s,U1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_43()
+def Test_cindent_43()
new
setl cindent ts=4 sw=4
setl cino=k2s,(0,W4
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_44()
+def Test_cindent_44()
new
setl cindent ts=4 sw=4
setl cino=k2s,u2
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_45()
+def Test_cindent_45()
new
setl cindent ts=4 sw=4
setl cino=k2s,(0,w1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_46()
+def Test_cindent_46()
new
setl cindent ts=4 sw=4
setl cino=k2,(s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
void func(void)
{
if (condition1
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_47()
+def Test_cindent_47()
new
setl cindent ts=4 sw=4
setl cino=N-s
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
NAMESPACESTART
/* valid namespaces with normal indent */
namespace
NAMESPACEEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
call search('^NAMESPACESTART')
exe "normal =/^NAMESPACEEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
NAMESPACESTART
/* valid namespaces with normal indent */
namespace
NAMESPACEEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_48()
+def Test_cindent_48()
new
setl cindent ts=4 sw=4
setl cino=j1,J1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
var bar = {
foo: {
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
var bar = {
foo: {
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_49()
+def Test_cindent_49()
new
setl cindent ts=4 sw=4
setl cino=j1,J1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
var foo = [
1,
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
var foo = [
1,
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_50()
+def Test_cindent_50()
new
setl cindent ts=4 sw=4
setl cino=j1,J1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
function bar() {
var foo = [
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
function bar() {
var foo = [
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_51()
+def Test_cindent_51()
new
setl cindent ts=4 sw=4
setl cino=j1,J1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
(function($){
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
(function($){
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_52()
+def Test_cindent_52()
new
setl cindent ts=4 sw=4
setl cino=j1,J1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
function init(options) {
$(this).data(class_name+'_public',$.extend({},{
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
function init(options) {
$(this).data(class_name+'_public',$.extend({},{
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_53()
+def Test_cindent_53()
new
setl cindent ts=4 sw=4
setl cino=j1,J1
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
(function($){
function init(options) {
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
(function($){
function init(options) {
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_54()
+def Test_cindent_54()
new
setl cindent ts=4 sw=4
setl cino=j1,J1,+2
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
JSSTART
// Results of JavaScript indent
// 1
JSEND
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('^JSSTART')
+ search('^JSSTART')
exe "normal =/^JSEND\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
JSSTART
// Results of JavaScript indent
// 1
JSEND
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_55()
+def Test_cindent_55()
new
setl cindent ts=4 sw=4
setl cino&
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
/* start of define */
{
}
/* end of define */
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('start of define')
+ search('start of define')
exe "normal =/end of define\n"
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
/* start of define */
{
}
/* end of define */
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_56()
+def Test_cindent_56()
new
setl cindent ts=4 sw=4
setl cino&
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
a = second/*bug*/*line;
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
- call search('a = second')
+ search('a = second')
normal ox
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
a = second/*bug*/*line;
x
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
" this was going beyond the end of the line.
-func Test_cindent_case()
+def Test_cindent_case()
new
- call setline(1, 'case x: // x')
+ setline(1, 'case x: // x')
set cindent
norm! f:a:
- call assert_equal('case x:: // x', getline(1))
+ assert_equal('case x:: // x', getline(1))
set cindent&
bwipe!
-endfunc
+enddef
" Test for changing multiple lines (using c) with cindent
-func Test_cindent_change_multline()
+def Test_cindent_change_multline()
new
setlocal cindent
- call setline(1, ['if (a)', '{', ' i = 1;', '}'])
+ setline(1, ['if (a)', '{', ' i = 1;', '}'])
normal! jc3jm = 2;
- call assert_equal("\tm = 2;", getline(2))
- close!
-endfunc
+ assert_equal("\tm = 2;", getline(2))
+ bwipe!
+enddef
" This was reading past the end of the line
-func Test_cindent_check_funcdecl()
+def Test_cindent_check_funcdecl()
new
sil norm o0\ f('\0\ f=L
bwipe!
-endfunc
+enddef
-func Test_cindent_scopedecls()
+def Test_cindent_scopedecls()
new
setl cindent ts=4 sw=4
setl cino=g0
setl cinsd+=public\ slots,signals
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
class Foo
{
public:
};
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal ]]=][
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
class Foo
{
public:
};
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_cindent_pragma()
+def Test_cindent_pragma()
new
setl cindent ts=4 sw=4
setl cino=Ps
- let code =<< trim [CODE]
+ var code =<< trim [CODE]
{
#pragma omp parallel
{
}
[CODE]
- call append(0, code)
+ append(0, code)
normal gg
normal =G
- let expected =<< trim [CODE]
+ var expected =<< trim [CODE]
{
#pragma omp parallel
{
}
[CODE]
+ assert_equal(expected, getline(1, '$'))
- call assert_equal(expected, getline(1, '$'))
- enew! | close
-endfunc
+ bwipe!
+enddef
-func Test_backslash_at_end_of_line()
+def Test_backslash_at_end_of_line()
new
exe "norm v>O'\\\<C-m>-"
exe "norm \<C-q>="
bwipe!
-endfunc
+enddef
-func Test_find_brace_backwards()
- " this was looking beyond the end of the line
+def Test_find_brace_backwards()
+ # this was looking beyond the end of the line
new
norm R/*
norm o0{
norm o//
norm V{=
- call assert_equal(['/*', ' 0{', '//'], getline(1, 3))
+ assert_equal(['/*', ' 0{', '//'], getline(1, 3))
bwipe!
-endfunc
+enddef
" vim: shiftwidth=2 sts=2 expandtab