Mercurial > vim
diff src/testdir/test_let.vim @ 16704:a927fdf9a4b0 v8.1.1354
patch 8.1.1354: getting a list of text lines is clumsy
commit https://github.com/vim/vim/commit/f5842c5a533346c4ff41ff666e465c85f1de35d5
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 19 18:41:26 2019 +0200
patch 8.1.1354: getting a list of text lines is clumsy
Problem: Getting a list of text lines is clumsy.
Solution: Add the =<< assignment. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4386)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 May 2019 18:45:05 +0200 |
parents | 6b0836727cf3 |
children | 98393772bddd |
line wrap: on
line diff
--- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -151,3 +151,57 @@ func Test_let_utf8_environment() let $a = 'ĀĒĪŌŪあいうえお' call assert_equal('ĀĒĪŌŪあいうえお', $a) endfunc + +" Test for the setting a variable using the heredoc syntax +func Test_let_heredoc() + let var1 =<< END +Some sample text + Text with indent + !@#$%^&*()-+_={}|[]\~`:";'<>?,./ +END + + call assert_equal(["Some sample text", "\tText with indent", " !@#$%^&*()-+_={}|[]\\~`:\";'<>?,./"], var1) + + let var2 =<< +Editor +. + call assert_equal(['Editor'], var2) + + let var3 =<<END +END + call assert_equal([], var3) + + let var3 =<<END +vim + +end + END +END +END + call assert_equal(['vim', '', 'end', ' END', 'END '], var3) + + let var1 =<< trim END + Line1 + Line2 + Line3 + END + END + call assert_equal(['Line1', ' Line2', "\tLine3", ' END'], var1) + + let var1 =<< trim + Line1 + . + call assert_equal([' Line1'], var1) + + call assert_fails('let v =<< marker', 'E991:') + call assert_fails('call WrongSyntax()', 'E488:') + call assert_fails('call MissingEnd()', 'E990:') +endfunc + +func WrongSyntax() + let fail =<< that there +endfunc + +func MissingEnd() + let fail =<< END +endfunc