зеркало из https://github.com/github/ruby.git
parse.y: should not deent concatenated string
* parse.y (xstring): reset heredoc indent after dedenting, so that following string literal would not be dedented. [ruby-core:72857] [Bug #11990] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c12af76763
Коммит
c8348d0cfa
|
@ -1,3 +1,9 @@
|
|||
Sat Jan 16 21:16:21 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (xstring): reset heredoc indent after dedenting,
|
||||
so that following string literal would not be dedented.
|
||||
[ruby-core:72857] [Bug #11990]
|
||||
|
||||
Sat Jan 16 17:24:24 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* enc/unicode.c: Artificial mapping to test buffer expansion code.
|
||||
|
|
1
parse.y
1
parse.y
|
@ -3950,6 +3950,7 @@ xstring : tXSTRING_BEG xstring_contents tSTRING_END
|
|||
/*%
|
||||
%*/
|
||||
heredoc_dedent($2);
|
||||
heredoc_indent = 0;
|
||||
/*%%%*/
|
||||
if (!node) {
|
||||
node = NEW_XSTR(STR_NEW0());
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
require 'test/unit'
|
||||
|
||||
class TestSyntax < Test::Unit::TestCase
|
||||
using Module.new {
|
||||
refine(Object) do
|
||||
def `(s) #`
|
||||
s
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
def assert_syntax_files(test)
|
||||
srcdir = File.expand_path("../../..", __FILE__)
|
||||
srcdir = File.join(srcdir, test)
|
||||
|
@ -493,7 +501,7 @@ e"
|
|||
end
|
||||
|
||||
def assert_dedented_heredoc(expect, result, mesg = "")
|
||||
%w[eos "eos" 'eos'].each do |eos|
|
||||
%w[eos "eos" 'eos' `eos`].each do |eos|
|
||||
assert_equal(eval("<<-#{eos}\n#{expect}eos\n"),
|
||||
eval("<<~#{eos}\n#{result}eos\n"),
|
||||
message(mesg) {"with #{eos}"})
|
||||
|
@ -587,6 +595,10 @@ e"
|
|||
eval("<<~#{eos} ' y'\n x\neos\n"),
|
||||
"#{bug11990} with #{eos}")
|
||||
end
|
||||
%w[eos "eos" 'eos' `eos`].each do |eos|
|
||||
_, expect = eval("[<<~#{eos}, ' x']\n"" y\n""eos\n")
|
||||
assert_equal(' x', expect, bug11990)
|
||||
end
|
||||
end
|
||||
|
||||
def test_lineno_after_heredoc
|
||||
|
|
Загрузка…
Ссылка в новой задаче