summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ripper/test_parser_events.rb28
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