0
0
mirror of https://github.com/vim/vim.git synced 2025-10-07 05:54:16 -04:00

patch 8.2.4770: cannot easily mix expression and heredoc

Problem:    Cannot easily mix expression and heredoc.
Solution:   Support  in heredoc. (Yegappan Lakshmanan, closes #10138)
This commit is contained in:
Yegappan Lakshmanan
2022-04-17 12:47:40 +01:00
committed by Bram Moolenaar
parent 68aaff4697
commit efbfa867a1
6 changed files with 315 additions and 25 deletions

View File

@@ -740,7 +740,7 @@ def Test_init_in_for_loop()
enddef
def Test_extend_list()
# using uninitilaized list assigns empty list
# using uninitialized list assigns empty list
var lines =<< trim END
var l1: list<number>
var l2 = l1
@@ -758,7 +758,7 @@ def Test_extend_list()
END
v9.CheckDefAndScriptSuccess(lines)
# appending to uninitialzed list from a function works
# appending to uninitialized list from a function works
lines =<< trim END
vim9script
var list: list<string>
@@ -2637,6 +2637,56 @@ def Test_using_s_var_in_function()
v9.CheckScriptSuccess(lines)
enddef
let g:someVar = 'X'
" Test for heredoc with Vim expressions.
" This messes up highlighting, keep it near the end.
def Test_heredoc_expr()
var code =<< trim eval END
var a = `=5 + 10`
var b = `=min([10, 6])` + `=max([4, 6])`
END
assert_equal(['var a = 15', 'var b = 6 + 6'], code)
code =<< eval trim END
var s = "`=$SOME_ENV_VAR`"
END
assert_equal(['var s = "somemore"'], code)
code =<< eval END
var s = "`=$SOME_ENV_VAR`"
END
assert_equal([' var s = "somemore"'], code)
code =<< eval trim END
let a = `abc`
let b = `=g:someVar`
let c = `
END
assert_equal(['let a = `abc`', 'let b = X', 'let c = `'], code)
var lines =<< trim LINES
var text =<< eval trim END
let b = `=
END
LINES
v9.CheckDefAndScriptFailure(lines, 'E1083:')
lines =<< trim LINES
var text =<< eval trim END
let b = `=abc
END
LINES
v9.CheckDefAndScriptFailure(lines, 'E1083:')
lines =<< trim LINES
var text =<< eval trim END
let b = `=`
END
LINES
v9.CheckDefAndScriptFailure(lines, 'E15:')
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker