1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_sexp.rb: test for fname

* test/ripper/test_sexp.rb (test_def_fname): test for fname in def
  statement.  [ruby-core:83089] [Bug #13967]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-10-04 05:30:44 +00:00
parent 8e03b79e06
commit b17a16c279

View file

@ -75,6 +75,18 @@ eot
assert_equal("z", z[1]) assert_equal("z", z[1])
end end
def test_def_fname
sexp = Ripper.sexp("def t; end")
_, (type, fname,) = search_sexp(:def, sexp)
assert_equal(:@ident, type)
assert_equal("t", fname)
sexp = Ripper.sexp("def <<; end")
_, (type, fname,) = search_sexp(:def, sexp)
assert_equal(:@op, type)
assert_equal("<<", fname)
end
def search_sexp(sym, sexp) def search_sexp(sym, sexp)
return sexp if !sexp or sexp[0] == sym return sexp if !sexp or sexp[0] == sym
sexp.find do |e| sexp.find do |e|