@@ -722,31 +722,33 @@ END
722722 LINES
723723 call v9.CheckScriptFailure (lines , ' E15:' )
724724
725- " Test for using heredoc in a single string using execute()
726- call assert_equal (" \n ['one', 'two']" ,
727- \ execute (" let x =<< trim END\n one\n two\n END\n echo x" ))
728- call assert_equal (" \n ['one', ' two']" ,
729- \ execute (" let x =<< trim END\n one\n two\n END\n echo x" ))
730- call assert_equal (" \n ['one', 'two']" ,
731- \ execute (" let x =<< trim END\n one\n two\n END\n echo x" ))
732- call assert_equal (" \n ['one', ' two']" ,
733- \ execute (" let x =<< trim END\n one\n two\n END\n echo x" ))
734- call assert_equal (" \n [' one', ' two']" ,
735- \ execute (" let x =<< END\n one\n two\n END\n echo x" ))
736- call assert_equal (" \n ['one', 'two']" ,
737- \ execute (" let x =<< END\n one\n two\n END\n echo x" ))
738- call assert_equal (" \n ['one', 'two']" ,
739- \ execute (" let x =<< END \" comment\n one\n two\n END\n echo x" ))
740- let cmd = ' execute("let x =<< END\n one\n two\necho x")'
741- call assert_fails (cmd, " E990: Missing end marker 'END'" )
742- let cmd = ' execute("let x =<<\n one\n two\necho x")'
743- call assert_fails (cmd, " E172: Missing marker" )
744- let cmd = ' execute("let x =<< trim\n one\n two\necho x")'
745- call assert_fails (cmd, " E172: Missing marker" )
746- let cmd = ' execute("let x =<< end\n one\n two\nend\necho x")'
747- call assert_fails (cmd, " E221: Marker cannot start with lower case letter" )
748- let cmd = ' execute("let x =<< eval END\n one\n two{y}\nEND\necho x")'
749- call assert_fails (cmd, ' E121: Undefined variable: y' )
725+ " Test for using heredoc in a single string using :execute or execute()
726+ for [cmd, res ] in items ({
727+ \ " let x =<< trim END\n one\n two\n END" : [' one' , ' two' ],
728+ \ " let x =<< trim END\n one\n two\n END" : [' one' , ' two' ],
729+ \ " let x =<< trim END\n one\n two\n END" : [' one' , ' two' ],
730+ \ " let x =<< trim END\n one\n two\n END" : [' one' , ' two' ],
731+ \ " let x =<< END\n one\n two\n END" : [' one' , ' two' ],
732+ \ " let x =<< END\n one\n two\n END" : [' one' , ' two' ],
733+ \ " let x =<< END \" comment\n one\n two\n END" : [' one' , ' two' ],
734+ \ })
735+ execute cmd
736+ call assert_equal (res , x )
737+ unlet x
738+ call assert_equal ($ " \n {string(res)}" , execute ($ " {cmd}\n echo x" ))
739+ unlet x
740+ endfor
741+ for [cmd, err] in items ({
742+ \ " let x =<<\n one\n two" : " E172:" ,
743+ \ " let x =<< trim\n one\n two" : " E172:" ,
744+ \ " let x =<< end\n one\n two\n end" : " E221:" ,
745+ \ " let x =<< END\n one\n two" : " E990: Missing end marker 'END'" ,
746+ \ " let x =<< END !\n one\n two\n END" : " E488: Trailing characters: !" ,
747+ \ " let x =<< eval END\n one\n two{y}\n END" : " E121: Undefined variable: y" ,
748+ \ })
749+ call assert_fails (' execute cmd' , err)
750+ call assert_fails (' call execute(cmd)' , err)
751+ endfor
750752
751753 " skipped heredoc
752754 if 0
0 commit comments