diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-07 14:39:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-07 14:39:52 +0000 |
commit | 9a28a29b870b5f45d370bc8f16c431b435f0bbb3 (patch) | |
tree | 1a8a83e8ca857731116ed37273b53d6812afd011 /test/ripper/test_sexp.rb | |
parent | 9f51e95fc18002939505ce352dee3f97efde3ada (diff) | |
download | ruby-9a28a29b870b5f45d370bc8f16c431b435f0bbb3.tar.gz |
parse.y: indented hereoc
* parse.y: add heredoc <<~ syntax. [Feature #9098]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper/test_sexp.rb')
-rw-r--r-- | test/ripper/test_sexp.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb index 8fc17fdd4a..557ae9b423 100644 --- a/test/ripper/test_sexp.rb +++ b/test/ripper/test_sexp.rb @@ -38,6 +38,27 @@ class TestRipper::Sexp < Test::Unit::TestCase assert_equal "foo\n", search_sexp(:@tstring_content, sexp)[1] end + def test_squiggly_heredoc + sexp = Ripper.sexp("<<~eot\n asdf\neot") + assert_equal "asdf\n", search_sexp(:@tstring_content, sexp)[1] + end + + def test_squiggly_heredoc_with_interpolated_expression + sexp1 = Ripper.sexp(<<-eos) +<<-eot +a\#{1}z +eot + eos + + sexp2 = Ripper.sexp(<<-eos) +<<~eot + a\#{1}z +eot + eos + + assert_equal clear_pos(sexp1), clear_pos(sexp2) + end + def search_sexp(sym, sexp) return sexp if !sexp or sexp[0] == sym sexp.find do |e| @@ -46,4 +67,18 @@ class TestRipper::Sexp < Test::Unit::TestCase end end end + + def clear_pos(sexp) + return sexp if !sexp + sexp.each do |e| + if Array === e + if e.size == 3 and Array === (last = e.last) and + last.size == 2 and Integer === last[0] and Integer === last[1] + last.clear + else + clear_pos(e) + end + end + end + end end if ripper_test |