summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-25 01:13:46 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-25 01:14:18 +0900
commit419b0596a2ada720ae1b3f2c1bd3ab5e12819ac8 (patch)
tree1cc99312173ec65bf81ecad861310f77174aeb20 /test/ripper
parent5dfe95d10ec1dfeb4e114911367d37214c3b3f07 (diff)
downloadruby-419b0596a2ada720ae1b3f2c1bd3ab5e12819ac8.tar.gz
[ripper] added endless method definition event tests
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_parser_events.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index b7118fcbb2..5b05624683 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -652,6 +652,11 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
}
assert_equal true, thru_def
assert_equal '[def(foo,[],bodystmt([void()]))]', parse('def foo ;end')
+
+ thru_def = false
+ tree = parse('def foo() = 42', :on_def) {thru_def = true}
+ assert_equal true, thru_def
+ assert_equal '[def(foo,[],42)]', tree
end
def test_defined
@@ -669,6 +674,11 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
thru_parse_error = false
tree = parse('def foo&.bar; end', :on_parse_error) {thru_parse_error = true}
assert_equal(true, thru_parse_error)
+
+ thru_defs = false
+ tree = parse('def foo.bar() = 42', :on_defs) {thru_defs = true}
+ assert_equal true, thru_defs
+ assert_equal '[defs(vcall(foo),.,bar,[],42)]', tree
end
def test_do_block