diff src/testdir/test_let.vim @ 16708:98393772bddd v8.1.1356

patch 8.1.1356: some text in heredoc assignment ends the text commit https://github.com/vim/vim/commit/8471e57026714c5a0faf89288ceef5231fb88d4f Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 19 21:37:18 2019 +0200 patch 8.1.1356: some text in heredoc assignment ends the text Problem: Some text in heredoc assignment ends the text. (Ozaki Kiichi) Solution: Recognize "let v =<<" and skip until the end.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 May 2019 21:45:06 +0200
parents a927fdf9a4b0
children 6990c1160ea5
line wrap: on
line diff
--- a/src/testdir/test_let.vim
+++ b/src/testdir/test_let.vim
@@ -152,6 +152,28 @@ func Test_let_utf8_environment()
   call assert_equal('ĀĒĪŌŪあいうえお', $a)
 endfunc
 
+func Test_let_heredoc_fails()
+  call assert_fails('let v =<< marker', 'E991:')
+
+  let text =<< trim END
+  func WrongSyntax()
+    let v =<< that there
+  endfunc
+  END
+  call writefile(text, 'XheredocFail')
+  call assert_fails('source XheredocFail', 'E126:')
+  call delete('XheredocFail')
+
+  let text =<< trim END
+  func MissingEnd()
+    let v =<< END
+  endfunc
+  END
+  call writefile(text, 'XheredocWrong')
+  call assert_fails('source XheredocWrong', 'E126:')
+  call delete('XheredocWrong')
+endfunc
+
 " Test for the setting a variable using the heredoc syntax
 func Test_let_heredoc()
   let var1 =<< END
@@ -193,15 +215,45 @@ END
   .
   call assert_equal(['  Line1'], var1)
 
-  call assert_fails('let v =<< marker', 'E991:')
-  call assert_fails('call WrongSyntax()', 'E488:')
-  call assert_fails('call MissingEnd()', 'E990:')
+  " ignore "endfunc"
+  let var1 =<< END
+something
 endfunc
+END
+  call assert_equal(['something', 'endfunc'], var1)
+
+  " ignore "endfunc" with trim
+  let var1 =<< trim END
+  something
+  endfunc
+  END
+  call assert_equal(['something', 'endfunc'], var1)
+
+  " ignore "python << xx"
+  let var1 =<<END
+something
+python << xx
+END
+  call assert_equal(['something', 'python << xx'], var1)
 
-func WrongSyntax()
-  let fail =<< that there
-endfunc
+  " ignore "python << xx" with trim
+  let var1 =<< trim END
+  something
+  python << xx
+  END
+  call assert_equal(['something', 'python << xx'], var1)
 
-func MissingEnd()
-  let fail =<< END
+  " ignore "append"
+  let var1 =<<
+something
+app
+.
+  call assert_equal(['something', 'app'], var1)
+
+  " ignore "append" with trim
+  let var1 =<< trim
+  something
+  app
+  .
+  call assert_equal(['something', 'app'], var1)
 endfunc