aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/003_cindent_spec.lua351
-rw-r--r--test/functional/legacy/fixeol_spec.lua72
2 files changed, 423 insertions, 0 deletions
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua
index 39de3e8280..19694550f4 100644
--- a/test/functional/legacy/003_cindent_spec.lua
+++ b/test/functional/legacy/003_cindent_spec.lua
@@ -901,6 +901,23 @@ describe('cindent', function()
{
111111111111111111;
}
+ void getstring() {
+ /* Raw strings */
+ const char* s = R"(
+ test {
+ # comment
+ field: 123
+ }
+ )";
+ }
+ void getstring() {
+ const char* s = R"foo(
+ test {
+ # comment
+ field: 123
+ }
+ )foo";
+ }
/* end of AUTO */
]=])
@@ -1790,6 +1807,23 @@ describe('cindent', function()
{
111111111111111111;
}
+ void getstring() {
+ /* Raw strings */
+ const char* s = R"(
+ test {
+ # comment
+ field: 123
+ }
+ )";
+ }
+ void getstring() {
+ const char* s = R"foo(
+ test {
+ # comment
+ field: 123
+ }
+ )foo";
+ }
/* end of AUTO */
]=])
@@ -4213,4 +4247,321 @@ describe('cindent', function()
JSEND
]=])
end)
+
+ it('javascript indent / vim-patch 7.4.670', function()
+ insert_([=[
+
+ JSSTART
+ // Results of JavaScript indent
+ // 1
+ (function(){
+ var a = [
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 2
+ (function(){
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 3
+ (function(){
+ var a = [
+ 0 +
+ // comment 1
+ 5 *
+ /* comment 2 */
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 4
+ {
+ var a = [
+ 0,
+ 1
+ ];
+ var b;
+ var c;
+ }
+
+ // 5
+ {
+ var a = [
+ [
+ 0
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 6
+ {
+ var a = [
+ [
+ 0,
+ 1
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 7
+ {
+ var a = [
+ // [
+ 0,
+ // 1
+ // ],
+ 2,
+ 3
+ ];
+ }
+
+ // 8
+ var x = [
+ (function(){
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ })
+ ];
+
+ // 9
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+
+ // 10
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ JSEND
+ ]=])
+
+ -- :set cino=j1,J1,+2
+ execute('set cino=j1,J1,+2')
+ execute('/^JSSTART')
+ feed('=/^JSEND<cr>')
+
+ expect([=[
+
+ JSSTART
+ // Results of JavaScript indent
+ // 1
+ (function(){
+ var a = [
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 2
+ (function(){
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 3
+ (function(){
+ var a = [
+ 0 +
+ // comment 1
+ 5 *
+ /* comment 2 */
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 4
+ {
+ var a = [
+ 0,
+ 1
+ ];
+ var b;
+ var c;
+ }
+
+ // 5
+ {
+ var a = [
+ [
+ 0
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 6
+ {
+ var a = [
+ [
+ 0,
+ 1
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 7
+ {
+ var a = [
+ // [
+ 0,
+ // 1
+ // ],
+ 2,
+ 3
+ ];
+ }
+
+ // 8
+ var x = [
+ (function(){
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ })
+ ];
+
+ // 9
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+
+ // 10
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ JSEND
+ ]=])
+ end)
end)
diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua
new file mode 100644
index 0000000000..578178d707
--- /dev/null
+++ b/test/functional/legacy/fixeol_spec.lua
@@ -0,0 +1,72 @@
+-- Tests for 'fixeol'
+
+local helpers = require('test.functional.helpers')
+local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('fixeol', function()
+ local function rmtestfiles()
+ os.remove('test.out')
+ os.remove('XXEol')
+ os.remove('XXNoEol')
+ os.remove('XXTestEol')
+ os.remove('XXTestNoEol')
+ end
+ setup(function()
+ clear()
+ rmtestfiles()
+ end)
+ teardown(function()
+ rmtestfiles()
+ end)
+
+ it('is working', function()
+ -- First write two test files – with and without trailing EOL.
+ -- Use Unix fileformat for consistency.
+ execute('set ff=unix')
+ execute('enew!')
+ feed('awith eol<esc>:w! XXEol<cr>')
+ execute('enew!')
+ execute('set noeol nofixeol')
+ feed('awithout eol<esc>:w! XXNoEol<cr>')
+ execute('set eol fixeol')
+ execute('bwipe XXEol XXNoEol')
+
+ -- Try editing files with 'fixeol' disabled.
+ execute('e! XXEol')
+ feed('ostays eol<esc>:set nofixeol<cr>')
+ execute('w! XXTestEol')
+ execute('e! XXNoEol')
+ feed('ostays without<esc>:set nofixeol<cr>')
+ execute('w! XXTestNoEol')
+ execute('bwipe XXEol XXNoEol XXTestEol XXTestNoEol')
+ execute('set fixeol')
+
+ -- Append "END" to each file so that we can see what the last written char was.
+ feed('ggdGaEND<esc>:w >>XXEol<cr>')
+ execute('w >>XXNoEol')
+ execute('w >>XXTestEol')
+ execute('w >>XXTestNoEol')
+
+ -- Concatenate the results.
+ execute('e! test.out')
+ feed('a0<esc>:$r XXEol<cr>')
+ execute('$r XXNoEol')
+ feed('Go1<esc>:$r XXTestEol<cr>')
+ execute('$r XXTestNoEol')
+ execute('w')
+
+ -- Assert buffer contents.
+ expect([=[
+ 0
+ with eol
+ END
+ without eolEND
+ 1
+ with eol
+ stays eol
+ END
+ without eol
+ stays withoutEND]=])
+ end)
+end)