diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-05-21 15:35:30 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-05-21 18:28:24 +0900 |
| commit | 50a534a1526e2b9f4ea41e44b802bd73f9cebbeb (patch) | |
| tree | 2d57265e65c180c6edb0401edcfa0cf206192b22 /test | |
| parent | 050bb06e66d8c08c43bf0cc74271f35c3edce25d (diff) | |
ripper: wrap endless method in bodystmt [Bug #17869]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4516
Diffstat (limited to 'test')
| -rw-r--r-- | test/ripper/test_parser_events.rb | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 413381ed1f..5bb8f120f2 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -672,12 +672,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase thru = {} tree = parse('def foo() = 42', events, &hook) assert_equal({on_def: true}, thru) - assert_equal '[def(foo,[],42)]', tree + assert_equal '[def(foo,[],bodystmt(42))]', tree thru = {} tree = parse('def foo() = 42 rescue 0', events, &hook) assert_equal({on_def: true}, thru) - assert_equal '[def(foo,[],rescue_mod(42,0))]', tree + assert_equal '[def(foo,[],bodystmt(rescue_mod(42,0)))]', tree thru = {} tree = parse('def foo=() = 42', events, &hook) @@ -686,6 +686,16 @@ class TestRipper::ParserEvents < Test::Unit::TestCase thru = {} tree = parse('def foo=() = 42 rescue 0', events, &hook) assert_equal({on_def: true, on_parse_error: true}, thru) + + thru = {} + tree = parse('def foo() = p 42', events, &hook) + assert_equal({on_def: true}, thru) + assert_equal '[def(foo,[],bodystmt(command(p,[42])))]', tree + + thru = {} + tree = parse('def foo() = p 42 rescue 0', events, &hook) + assert_equal({on_def: true}, thru) + assert_equal '[def(foo,[],bodystmt(rescue_mod(command(p,[42]),0)))]', tree end def test_defined @@ -713,12 +723,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase thru = {} tree = parse('def foo.bar() = 42', events, &hook) assert_equal({on_defs: true}, thru) - assert_equal '[defs(vcall(foo),.,bar,[],42)]', tree + assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(42))]', tree thru = {} tree = parse('def foo.bar() = 42 rescue 0', events, &hook) assert_equal({on_defs: true}, thru) - assert_equal '[defs(vcall(foo),.,bar,[],rescue_mod(42,0))]', tree + assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(rescue_mod(42,0)))]', tree thru = {} tree = parse('def foo.bar=() = 42', events, &hook) @@ -727,6 +737,16 @@ class TestRipper::ParserEvents < Test::Unit::TestCase thru = {} tree = parse('def foo.bar=() = 42 rescue 0', events, &hook) assert_equal({on_defs: true, on_parse_error: true}, thru) + + thru = {} + tree = parse('def foo.bar() = p 42', events, &hook) + assert_equal({on_defs: true}, thru) + assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(command(p,[42])))]', tree + + thru = {} + tree = parse('def foo.bar() = p 42 rescue 0', events, &hook) + assert_equal({on_defs: true}, thru) + assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(rescue_mod(command(p,[42]),0)))]', tree end def test_do_block |
