From 4bcf8c15b3079ca72d6557890b50b35565fcd577 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 29 Apr 2023 08:12:32 +0800 Subject: vim-patch:8.2.0578: heredoc for interfaces does not support "trim" Problem: Heredoc for interfaces does not support "trim". Solution: Update the script heredoc support to be same as the :let command. (Yegappan Lakshmanan, closes vim/vim#5916) https://github.com/vim/vim/commit/6c2b7b8055b96463f78abb70f58c4c6d6d4b9d55 --- test/old/testdir/test_perl.vim | 12 +++++++++--- test/old/testdir/test_python2.vim | 19 +++++++++++++++++++ test/old/testdir/test_python3.vim | 33 +++++++++++++++++++++++++++------ test/old/testdir/test_pyx2.vim | 27 +++++++++++++++++++++++---- test/old/testdir/test_pyx3.vim | 27 +++++++++++++++++++++++---- test/old/testdir/test_ruby.vim | 27 ++++++++++++++++++++++----- 6 files changed, 123 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/old/testdir/test_perl.vim b/test/old/testdir/test_perl.vim index 558d0a5d6b..5cef74193b 100644 --- a/test/old/testdir/test_perl.vim +++ b/test/old/testdir/test_perl.vim @@ -224,11 +224,11 @@ endfunc func Test_stdio() throw 'skipped: TODO: ' redir =>l:out - perl < var - pyx << EOF -import sys -print(sys.version) -EOF + pyx << trim EOF + import sys + print(sys.version) + EOF redir END call assert_match(s:py2pattern, split(var)[0]) endfunc @@ -79,3 +79,22 @@ func Test_Catch_Exception_Message() call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception ) endtry endfunc + +" Test for various heredoc syntaxes +func Test_pyx2_heredoc() + pyx << END +result='A' +END + pyx << +result+='B' +. + pyx << trim END + result+='C' + END + pyx << trim + result+='D' + . + call assert_equal('ABCD', pyxeval('result')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_pyx3.vim b/test/old/testdir/test_pyx3.vim index db39f5134a..a4666fe3d4 100644 --- a/test/old/testdir/test_pyx3.vim +++ b/test/old/testdir/test_pyx3.vim @@ -15,10 +15,10 @@ endfunc func Test_pyx() redir => var - pyx << EOF -import sys -print(sys.version) -EOF + pyx << trim EOF + import sys + print(sys.version) + EOF redir END call assert_match(s:py3pattern, split(var)[0]) endfunc @@ -79,3 +79,22 @@ func Test_Catch_Exception_Message() call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception ) endtry endfunc + +" Test for various heredoc syntaxes +func Test_pyx3_heredoc() + pyx << END +result='A' +END + pyx << +result+='B' +. + pyx << trim END + result+='C' + END + pyx << trim + result+='D' + . + call assert_equal('ABCD', pyxeval('result')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_ruby.vim b/test/old/testdir/test_ruby.vim index 1fbf3392d9..80d39309ea 100644 --- a/test/old/testdir/test_ruby.vim +++ b/test/old/testdir/test_ruby.vim @@ -341,11 +341,11 @@ func Test_ruby_Vim_evaluate_list() call setline(line('$'), ['2 line 2']) ruby Vim.command("normal /^2\n") let l = ["abc", "def"] - ruby << EOF - curline = $curbuf.line_number - l = Vim.evaluate("l"); - $curbuf.append(curline, l.join("|")) -EOF + ruby << trim EOF + curline = $curbuf.line_number + l = Vim.evaluate("l"); + $curbuf.append(curline, l.join("|")) + EOF normal j .rubydo $_ = $_.gsub(/\|/, '/') call assert_equal('abc/def', getline('$')) @@ -414,4 +414,21 @@ func Test_rubyeval_error() call assert_fails('call rubyeval("(")') endfunc +" Test for various heredoc syntax +func Test_ruby_heredoc() + ruby << END +Vim.command('let s = "A"') +END + ruby << +Vim.command('let s ..= "B"') +. + ruby << trim END + Vim.command('let s ..= "C"') + END + ruby << trim + Vim.command('let s ..= "D"') + . + call assert_equal('ABCD', s) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit