From afce081b90c1e2c50c3507758c7558a0dfa1f33e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:18:03 +0200 Subject: Adding upstream version 2:8.2.2434. Signed-off-by: Daniel Baumann --- runtime/indent/testdir/README.txt | 97 ++++++++++++++++++++++++++ runtime/indent/testdir/html.in | 66 ++++++++++++++++++ runtime/indent/testdir/html.ok | 66 ++++++++++++++++++ runtime/indent/testdir/matlab.in | 89 ++++++++++++++++++++++++ runtime/indent/testdir/matlab.ok | 89 ++++++++++++++++++++++++ runtime/indent/testdir/runtest.vim | 134 ++++++++++++++++++++++++++++++++++++ runtime/indent/testdir/sshconfig.in | 53 ++++++++++++++ runtime/indent/testdir/sshconfig.ok | 53 ++++++++++++++ runtime/indent/testdir/tcl.in | 19 +++++ runtime/indent/testdir/tcl.ok | 19 +++++ runtime/indent/testdir/vim.in | 85 +++++++++++++++++++++++ runtime/indent/testdir/vim.ok | 85 +++++++++++++++++++++++ runtime/indent/testdir/xml.in | 32 +++++++++ runtime/indent/testdir/xml.ok | 32 +++++++++ runtime/indent/testdir/yaml.in | 19 +++++ runtime/indent/testdir/yaml.ok | 19 +++++ 16 files changed, 957 insertions(+) create mode 100644 runtime/indent/testdir/README.txt create mode 100644 runtime/indent/testdir/html.in create mode 100644 runtime/indent/testdir/html.ok create mode 100644 runtime/indent/testdir/matlab.in create mode 100644 runtime/indent/testdir/matlab.ok create mode 100644 runtime/indent/testdir/runtest.vim create mode 100644 runtime/indent/testdir/sshconfig.in create mode 100644 runtime/indent/testdir/sshconfig.ok create mode 100644 runtime/indent/testdir/tcl.in create mode 100644 runtime/indent/testdir/tcl.ok create mode 100644 runtime/indent/testdir/vim.in create mode 100644 runtime/indent/testdir/vim.ok create mode 100644 runtime/indent/testdir/xml.in create mode 100644 runtime/indent/testdir/xml.ok create mode 100644 runtime/indent/testdir/yaml.in create mode 100644 runtime/indent/testdir/yaml.ok (limited to 'runtime/indent/testdir') diff --git a/runtime/indent/testdir/README.txt b/runtime/indent/testdir/README.txt new file mode 100644 index 0000000..6597560 --- /dev/null +++ b/runtime/indent/testdir/README.txt @@ -0,0 +1,97 @@ +TESTING INDENT SCRIPTS + +We'll use FILETYPE for the filetype name here. + + +FORMAT OF THE FILETYPE.IN FILE + +First of all, create a FILETYPE.in file. It should contain: + +- A modeline setting the 'filetype' and any other option values. + This must work like a comment for FILETYPE. E.g. for vim: + " vim: set ft=vim sw=4 : + +- At least one block of lines to indent, prefixed with START_INDENT and + followed by END_INDENT. These lines must also look like a comment for your + FILETYPE. You would normally leave out all indent, so that the effect of + the indent command results in adding indent. Example: + + " START_INDENT + func Some() + let x = 1 + endfunc + " END_INDENT + + If you just want to test normal indenting with default options, you can make + this a large number of lines. Just add all kinds of language constructs, + nested statements, etc. with valid syntax. + +- Optionally, add lines with INDENT_EXE after START_INDENT, followed by a Vim + command. This will be executed before indenting the lines. Example: + + " START_INDENT + " INDENT_EXE let g:vim_indent_cont = 6 + let cmd = + \ 'some ' + \ 'string' + " END_INDENT + + Note that the command is not undone, you may need to reverse the effect for + the next block of lines. + +- Alternatively to indenting all the lines between START_INDENT and + END_INDENT, use an INDENT_AT line, which specifies a pattern to find the + line to indent. Example: + + " START_INDENT + " INDENT_AT this-line + func Some() + let f = x " this-line + endfunc + " END_INDENT + + Alternatively you can use INDENT_NEXT to indent the line below the matching + pattern. Keep in mind that quite often it will indent relative to the + matching line: + + " START_INDENT + " INDENT_NEXT next-line + func Some() + " next-line + let f = x + endfunc + " END_INDENT + + Or use INDENT_PREV to indent the line above the matching pattern: + + " START_INDENT + " INDENT_PREV prev-line + func Some() + let f = x + " prev-line + endfunc + " END_INDENT + +It's best to keep the whole file valid for FILETYPE, so that syntax +highlighting works normally, and any indenting that depends on the syntax +highlighting also works. + + +RUNNING THE TEST + +Before running the test, create a FILETYPE.ok file. You can leave it empty at +first. + +Now run "make test" from the parent directory. After Vim has done the +indenting you will see a FILETYPE.fail file. This contains the actual result +of indenting, and it's different from the FILETYPE.ok file. + +Check the contents of the FILETYPE.fail file. If it is perfectly OK, then +rename it to overwrite the FILETYPE.ok file. If you now run "make test" again, +the test will pass and create a FILETYPE.out file, which is identical to the +FILETYPE.ok file. The FILETYPE.fail file will be deleted. + +If you try to run "make test" again you will notice that nothing happens, +because the FILETYPE.out file already exists. Delete it, or do "make clean", +so that the text runs again. If you edit the FILETYPE.in file, so that it's +newer than the FILETYPE.out file, the test will also run. diff --git a/runtime/indent/testdir/html.in b/runtime/indent/testdir/html.in new file mode 100644 index 0000000..1acf8c0 --- /dev/null +++ b/runtime/indent/testdir/html.in @@ -0,0 +1,66 @@ +" vim: set ft=html sw=4 : + + +" START_INDENT + + + + +
+
+text +
+
+ +
+text +
+ +
+text +
+ +
+text +
+ +
+
+dd text +
+
+dt text +
+
+ + + + +" END_INDENT + +% START_INDENT +% INDENT_EXE let g:html_indent_style1 = "inc" +% INDENT_EXE let g:html_indent_script1 = "zero" +% INDENT_EXE call HtmlIndent_CheckUserSettings() + + + + + + +% END_INDENT diff --git a/runtime/indent/testdir/html.ok b/runtime/indent/testdir/html.ok new file mode 100644 index 0000000..ba2fd3f --- /dev/null +++ b/runtime/indent/testdir/html.ok @@ -0,0 +1,66 @@ +" vim: set ft=html sw=4 : + + +" START_INDENT + + + + +
+
+ text +
+
+ +
+ text +
+ +
+ text +
+ +
+ text +
+ +
+
+ dd text +
+
+ dt text +
+
+ + + + +" END_INDENT + +% START_INDENT +% INDENT_EXE let g:html_indent_style1 = "inc" +% INDENT_EXE let g:html_indent_script1 = "zero" +% INDENT_EXE call HtmlIndent_CheckUserSettings() + + + + + + +% END_INDENT diff --git a/runtime/indent/testdir/matlab.in b/runtime/indent/testdir/matlab.in new file mode 100644 index 0000000..b997ec8 --- /dev/null +++ b/runtime/indent/testdir/matlab.in @@ -0,0 +1,89 @@ +% vim: set ft=matlab sw=4 : + +% START_INDENT +if true +disp foo +elseif false +disp bar +end +% END_INDENT + +% START_INDENT +try +statements +catch exception +statements +end +% END_INDENT + +% START_INDENT +if true, ... +if true +disp hello +end +end +% END_INDENT + +% START_INDENT +switch a +case expr +if true, foo; end +disp hello +otherwise +disp bar +end +% END_INDENT + +% START_INDENT +if true +A(1:end - 1) +C{1:end - 1} +disp foo +end +% END_INDENT + +% START_INDENT +A = [{ +} +] ... +disp foo +disp bar +% END_INDENT + +% START_INDENT +if true +% end +%% end +disp foo +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 0 +function foo +disp foo +function nested +disp bar +end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 1 +function foo +disp foo +function nested +disp bar +end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 2 +function foo +disp foo +function nested +disp bar +end +end +% END_INDENT diff --git a/runtime/indent/testdir/matlab.ok b/runtime/indent/testdir/matlab.ok new file mode 100644 index 0000000..df4e7b2 --- /dev/null +++ b/runtime/indent/testdir/matlab.ok @@ -0,0 +1,89 @@ +% vim: set ft=matlab sw=4 : + +% START_INDENT +if true + disp foo +elseif false + disp bar +end +% END_INDENT + +% START_INDENT +try + statements +catch exception + statements +end +% END_INDENT + +% START_INDENT +if true, ... + if true + disp hello + end +end +% END_INDENT + +% START_INDENT +switch a + case expr + if true, foo; end + disp hello + otherwise + disp bar +end +% END_INDENT + +% START_INDENT +if true + A(1:end - 1) + C{1:end - 1} + disp foo +end +% END_INDENT + +% START_INDENT +A = [{ + } + ] ... + disp foo +disp bar +% END_INDENT + +% START_INDENT +if true + % end + %% end + disp foo +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 0 +function foo +disp foo + function nested + disp bar + end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 1 +function foo +disp foo + function nested + disp bar + end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 2 +function foo + disp foo + function nested + disp bar + end +end +% END_INDENT diff --git a/runtime/indent/testdir/runtest.vim b/runtime/indent/testdir/runtest.vim new file mode 100644 index 0000000..6bbd33c --- /dev/null +++ b/runtime/indent/testdir/runtest.vim @@ -0,0 +1,134 @@ +" Runs all the indent tests for which there is no .out file. +" +" Current directory must be runtime/indent. + +" Only do this with the +eval feature +if 1 + +set nocp +filetype indent on +syn on +set nowrapscan +set report=9999 +set modeline + +au! SwapExists * call HandleSwapExists() +func HandleSwapExists() + " Ignore finding a swap file for the test input and output, the user might be + " editing them and that's OK. + if expand('') =~ '.*\.\(in\|out\|fail\|ok\)' + let v:swapchoice = 'e' + endif +endfunc + +let failed_count = 0 +for fname in glob('testdir/*.in', 1, 1) + let root = substitute(fname, '\.in', '', '') + + " Execute the test if the .out file does not exist of when the .in file is + " newer. + let in_time = getftime(fname) + let out_time = getftime(root . '.out') + if out_time < 0 || in_time > out_time + call delete(root . '.fail') + call delete(root . '.out') + + set sw& ts& filetype= + exe 'split ' . fname + + let did_some = 0 + let failed = 0 + let end = 1 + while 1 + " Indent all the lines between "START_INDENT" and "END_INDENT" + exe end + let start = search('\') + let end = search('\') + if start <= 0 || end <= 0 || end <= start + if did_some == 0 + call append(0, 'ERROR: START_INDENT and/or END_INDENT not found') + let failed = 1 + endif + break + else + let did_some = 1 + + " Execute all commands marked with INDENT_EXE and find any pattern. + let lnum = start + let pattern = '' + let at = '' + while 1 + exe lnum + 1 + let lnum_exe = search('\') + exe lnum + 1 + let indent_at = search('\') + if lnum_exe > 0 && lnum_exe < end && (indent_at <= 0 || lnum_exe < indent_at) + exe substitute(getline(lnum_exe), '.*INDENT_EXE', '', '') + let lnum = lnum_exe + let start = lnum + elseif indent_at > 0 && indent_at < end + if pattern != '' + call append(indent_at, 'ERROR: duplicate pattern') + let failed = 1 + break + endif + let text = getline(indent_at) + let pattern = substitute(text, '.*INDENT_\S*\s*', '', '') + let at = substitute(text, '.*INDENT_\(\S*\).*', '\1', '') + let lnum = indent_at + let start = lnum + else + break + endif + endwhile + + exe start + 1 + if pattern == '' + exe 'normal =' . (end - 1) . 'G' + else + let lnum = search(pattern) + if lnum <= 0 + call append(indent_at, 'ERROR: pattern not found: ' . pattern) + let failed = 1 + break + endif + if at == 'AT' + exe lnum + elseif at == 'NEXT' + exe lnum + 1 + else + exe lnum - 1 + endif + normal == + endif + endif + endwhile + + if !failed + " Check the resulting text equals the .ok file. + if getline(1, '$') != readfile(root . '.ok') + let failed = 1 + endif + endif + + if failed + let failed_count += 1 + exe 'write ' . root . '.fail' + echoerr 'Test ' . fname . ' FAILED!' + else + exe 'write ' . root . '.out' + echo "Test " . fname . " OK\n" + endif + + quit! " close the indented file + endif +endfor + +" Matching "if 1" at the start. +endif + +if failed_count > 0 + " have make report an error + cquit +endif +qall! diff --git a/runtime/indent/testdir/sshconfig.in b/runtime/indent/testdir/sshconfig.in new file mode 100644 index 0000000..87b998e --- /dev/null +++ b/runtime/indent/testdir/sshconfig.in @@ -0,0 +1,53 @@ +# vim: set filetype=sshconfig shiftwidth=4 expandtab : + +# START_INDENT +Host myhost +User myuser +PasswordAuthentication no +# END_INDENT + +# START_INDENT +Host aaa +User bbb +Host ccc +Host ddd +# END_INDENT + +# START_INDENT +host aaa +HOST bbb +hoSt ccc +match ddd +MATCH eee +MatCH fff +# END_INDENT + +# START_INDENT +Host aaa +User host +PasswordAuthentication no +Host * +User user +PasswordAuthentication no +Host match +User bbb +# END_INDENT + +# START_INDENT +Host tab +User myuser +# END_INDENT + +# START_INDENT +Host mix +User myuser +# END_INDENT + +# START_INDENT +Host aaa +User bbb +Match ccc +User ddd +HostKeyAlgorithms ssh-ed25519 +Match eee +# END_INDENT diff --git a/runtime/indent/testdir/sshconfig.ok b/runtime/indent/testdir/sshconfig.ok new file mode 100644 index 0000000..b24b7cf --- /dev/null +++ b/runtime/indent/testdir/sshconfig.ok @@ -0,0 +1,53 @@ +# vim: set filetype=sshconfig shiftwidth=4 expandtab : + +# START_INDENT +Host myhost + User myuser + PasswordAuthentication no +# END_INDENT + +# START_INDENT +Host aaa + User bbb +Host ccc +Host ddd +# END_INDENT + +# START_INDENT +host aaa +HOST bbb +hoSt ccc +match ddd +MATCH eee +MatCH fff +# END_INDENT + +# START_INDENT +Host aaa + User host + PasswordAuthentication no +Host * + User user + PasswordAuthentication no +Host match + User bbb +# END_INDENT + +# START_INDENT +Host tab + User myuser +# END_INDENT + +# START_INDENT +Host mix + User myuser +# END_INDENT + +# START_INDENT +Host aaa + User bbb +Match ccc + User ddd + HostKeyAlgorithms ssh-ed25519 +Match eee +# END_INDENT diff --git a/runtime/indent/testdir/tcl.in b/runtime/indent/testdir/tcl.in new file mode 100644 index 0000000..c769d5b --- /dev/null +++ b/runtime/indent/testdir/tcl.in @@ -0,0 +1,19 @@ +# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab : + +# START_INDENT +proc abc {} { +set a 5 +if {[some_cmd]==1} { +foreach i [list {1 2 3}] { +# Does this comment affect anything? +puts $i +} +} +} + +command_with_a_long_time -arg1 "First" \ +-arg2 "Second" \ +-arg3 "Third" + +puts "Move indent back after line continuation is complete" +# END_INDENT \ No newline at end of file diff --git a/runtime/indent/testdir/tcl.ok b/runtime/indent/testdir/tcl.ok new file mode 100644 index 0000000..77f24e9 --- /dev/null +++ b/runtime/indent/testdir/tcl.ok @@ -0,0 +1,19 @@ +# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab : + +# START_INDENT +proc abc {} { + set a 5 + if {[some_cmd]==1} { + foreach i [list {1 2 3}] { + # Does this comment affect anything? + puts $i + } + } +} + +command_with_a_long_time -arg1 "First" \ + -arg2 "Second" \ + -arg3 "Third" + +puts "Move indent back after line continuation is complete" +# END_INDENT diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in new file mode 100644 index 0000000..f652dbd --- /dev/null +++ b/runtime/indent/testdir/vim.in @@ -0,0 +1,85 @@ +" vim: set ft=vim sw=4 : + +" START_INDENT + +func Some() +let x = 1 +endfunc + +let cmd = +\ 'some ' +\ 'string' + +if 1 +let x = [ +\ ] +endif + +" END_INDENT + +" START_INDENT +" INDENT_EXE let g:vim_indent_cont = 6 + +let cmd = +\ 'some ' +\ 'string' + +" END_INDENT + +" START_INDENT +" INDENT_EXE let g:vim_indent_cont = 5 + +let list = [ +\ 'one', +\ 'two'] + +" END_INDENT + +" START_INDENT +" INDENT_EXE unlet g:vim_indent_cont + +let list = [ +'one', +'two', +] +echo + +" END_INDENT + +" START_INDENT +" INDENT_AT this-line +func Some() +let f = x " this-line +endfunc +" END_INDENT + +" START_INDENT +" INDENT_NEXT next-line +func Some() + " next-line +let f = x +endfunc +" END_INDENT + +" START_INDENT +" INDENT_PREV prev-line +func Some() +let f = x +" prev-line +endfunc +" END_INDENT + +" START_INDENT +let a =<< END +nothing +END +" END_INDENT + +" START_INDENT +" INDENT_AT this-line +let a=<< trim END + blah + blah + blah this-line +END +" END_INDENT diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok new file mode 100644 index 0000000..b8592c1 --- /dev/null +++ b/runtime/indent/testdir/vim.ok @@ -0,0 +1,85 @@ +" vim: set ft=vim sw=4 : + +" START_INDENT + +func Some() + let x = 1 +endfunc + +let cmd = + \ 'some ' + \ 'string' + +if 1 + let x = [ + \ ] +endif + +" END_INDENT + +" START_INDENT +" INDENT_EXE let g:vim_indent_cont = 6 + +let cmd = + \ 'some ' + \ 'string' + +" END_INDENT + +" START_INDENT +" INDENT_EXE let g:vim_indent_cont = 5 + +let list = [ + \ 'one', + \ 'two'] + +" END_INDENT + +" START_INDENT +" INDENT_EXE unlet g:vim_indent_cont + +let list = [ + 'one', + 'two', + ] +echo + +" END_INDENT + +" START_INDENT +" INDENT_AT this-line +func Some() + let f = x " this-line +endfunc +" END_INDENT + +" START_INDENT +" INDENT_NEXT next-line +func Some() + " next-line + let f = x +endfunc +" END_INDENT + +" START_INDENT +" INDENT_PREV prev-line +func Some() + let f = x +" prev-line +endfunc +" END_INDENT + +" START_INDENT +let a =<< END + nothing +END +" END_INDENT + +" START_INDENT +" INDENT_AT this-line +let a=<< trim END + blah + blah + blah this-line +END +" END_INDENT diff --git a/runtime/indent/testdir/xml.in b/runtime/indent/testdir/xml.in new file mode 100644 index 0000000..b633334 --- /dev/null +++ b/runtime/indent/testdir/xml.in @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/runtime/indent/testdir/xml.ok b/runtime/indent/testdir/xml.ok new file mode 100644 index 0000000..cfdf701 --- /dev/null +++ b/runtime/indent/testdir/xml.ok @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/runtime/indent/testdir/yaml.in b/runtime/indent/testdir/yaml.in new file mode 100644 index 0000000..8515e17 --- /dev/null +++ b/runtime/indent/testdir/yaml.in @@ -0,0 +1,19 @@ +# vim: set ft=yaml sw=2 et : + +# START_INDENT +map1: +sub1: +- list item +map2: +- another list +# END_INDENT + +# START_INDENT +map: &anchor +map: val +# END_INDENT + +# START_INDENT +map: multiline +value +# END_INDENT diff --git a/runtime/indent/testdir/yaml.ok b/runtime/indent/testdir/yaml.ok new file mode 100644 index 0000000..5ca2871 --- /dev/null +++ b/runtime/indent/testdir/yaml.ok @@ -0,0 +1,19 @@ +# vim: set ft=yaml sw=2 et : + +# START_INDENT +map1: + sub1: + - list item +map2: + - another list +# END_INDENT + +# START_INDENT +map: &anchor +map: val +# END_INDENT + +# START_INDENT +map: multiline + value +# END_INDENT -- cgit v1.2.3