diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-20 05:50:53 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-20 05:50:53 +0000 |
| commit | d007c58333bc5f072e99b3706e0f471a5b18da67 (patch) | |
| tree | 6bdbfe6d6de74d20a33c80388c49ade55e5c090c /test | |
| parent | 56ab5a31f8631feec0971135ad43725c2ff57c38 (diff) | |
| download | ruby-d007c58333bc5f072e99b3706e0f471a5b18da67.tar.gz ruby-d007c58333bc5f072e99b3706e0f471a5b18da67.tar.xz ruby-d007c58333bc5f072e99b3706e0f471a5b18da67.zip | |
* parse.y (parser_here_document): dispatch delayed heredoc
contents. based on a patch from Andy Keep in [ruby-core:24855].
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/ripper/dummyparser.rb | 2 | ||||
| -rw-r--r-- | test/ripper/test_parser_events.rb | 14 | ||||
| -rw-r--r-- | test/ripper/test_scanner_events.rb | 10 |
3 files changed, 20 insertions, 6 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb index cf0b5d2a3..ec8800b17 100644 --- a/test/ripper/dummyparser.rb +++ b/test/ripper/dummyparser.rb @@ -51,7 +51,7 @@ class DummyParser < Ripper class << self; self; end.class_eval do define_method(name) do |*a, &b| result = super(*a, &b) - yield + yield(*a) result end end diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 80199ecce..2494434d8 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -202,6 +202,20 @@ class TestRipper_ParserEvents < Test::Unit::TestCase assert_equal true, thru_bodystmt end + def test_heredoc + bug1921 = '[ruby-core:24855]' + thru_heredoc_beg = false + tree = parse("<<EOS\nheredoc\nEOS\n", :on_heredoc_beg) {thru_heredoc_beg = true} + assert_equal true, thru_heredoc_beg + assert_match(/string_content\(\),heredoc\n/, tree, bug1921) + heredoc = nil + parse("<<EOS\nheredoc1\nheredoc2\nEOS\n", :on_string_add) {|n, s| heredoc = s} + assert_equal("heredoc1\nheredoc2\n", heredoc, bug1921) + heredoc = nil + parse("<<-EOS\nheredoc1\nheredoc2\n\tEOS\n", :on_string_add) {|n, s| heredoc = s} + assert_equal("heredoc1\nheredoc2\n", heredoc, bug1921) + end + =begin def test_brace_block assert_equal true, $thru__brace_block diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 800147c5b..423fe8f77 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -628,9 +628,9 @@ class TestRipper_ScannerEvents < Test::Unit::TestCase scan('tstring_content', "<<EOS\nheredoc\nEOS") assert_equal ["heredoc\n"], scan('tstring_content', "<<EOS\nheredoc\nEOS\n") - assert_equal ["heredoc \n"], - scan('tstring_content', "<<EOS\nheredoc \nEOS \n") - assert_equal ["heredoc\n"], + assert_equal ["here\ndoc \nEOS \n"], + scan('tstring_content', "<<EOS\nhere\ndoc \nEOS \n") + assert_equal ["heredoc\n\tEOS \n"], scan('tstring_content', "<<-EOS\nheredoc\n\tEOS \n") end @@ -641,9 +641,9 @@ class TestRipper_ScannerEvents < Test::Unit::TestCase scan('heredoc_end', "<<EOS\nheredoc\nEOS") assert_equal ["EOS\n"], scan('heredoc_end', "<<EOS\nheredoc\nEOS\n") - assert_equal ["EOS \n"], + assert_equal [], scan('heredoc_end', "<<EOS\nheredoc\nEOS \n") - assert_equal ["\tEOS \n"], + assert_equal [], scan('heredoc_end', "<<-EOS\nheredoc\n\tEOS \n") end |
