summaryrefslogtreecommitdiff
path: root/test/ruby/test_syntax.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 12:26:12 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 12:26:12 +0000
commita61019eee34e0e0f3463da22cc0f3e62eeebf429 (patch)
tree55461bc899de6294f5fd2fa3690b27a762c2f92f /test/ruby/test_syntax.rb
parentba02d4b03bf536b24786f5b5982a08b44cf9d427 (diff)
merge revision(s) 53541,53555,53570: [Backport #11990]
* parse.y (string1): reset heredoc indent fore each string leteral so that concatenated string would not be dedented. [ruby-core:72857] [Bug #11990] * 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/branches/ruby_2_3@54399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_syntax.rb')
-rw-r--r--test/ruby/test_syntax.rb32
1 files changed, 28 insertions, 4 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 1daf7b2d91..70b3934d4f 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -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,10 +501,13 @@ e"
end
def assert_dedented_heredoc(expect, result, mesg = "")
- %w[eos "eos" 'eos'].each do |eos|
- assert_equal(eval("<<-#{eos}\n#{expect}eos\n"),
- eval("<<~#{eos}\n#{result}eos\n"),
- message(mesg) {"with #{eos}"})
+ all_assertions(mesg) do |a|
+ %w[eos "eos" 'eos' `eos`].each do |eos|
+ a.for(eos) do
+ assert_equal(eval("<<-#{eos}\n#{expect}eos\n"),
+ eval("<<~#{eos}\n#{result}eos\n"))
+ end
+ end
end
end
@@ -580,6 +591,19 @@ e"
assert_dedented_heredoc(expect, result)
end
+ def test_dedented_heredoc_with_concatenation
+ bug11990 = '[ruby-core:72857] [Bug #11990] concatenated string should not be dedented'
+ %w[eos "eos" 'eos'].each do |eos|
+ assert_equal("x\n y",
+ 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
bug7559 = '[ruby-dev:46737]'
expected, _, actual = __LINE__, <<eom, __LINE__