From b17a16c279f6738070d1cb2de1f2139692850028 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 4 Oct 2017 05:30:44 +0000 Subject: [PATCH] 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 --- test/ripper/test_sexp.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb index d3afbb2399..bbab398922 100644 --- a/test/ripper/test_sexp.rb +++ b/test/ripper/test_sexp.rb @@ -75,6 +75,18 @@ eot assert_equal("z", z[1]) 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) return sexp if !sexp or sexp[0] == sym sexp.find do |e|