ruby-changes:36574
From: nobu <ko1@a...>
Date: Sun, 30 Nov 2014 20:06:07 +0900 (JST)
Subject: [ruby-changes:36574] nobu:r48655 (trunk): parse.y: fix a typo
nobu 2014-11-30 20:05:58 +0900 (Sun, 30 Nov 2014) New Revision: 48655 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48655 Log: parse.y: fix a typo * parse.y (regexp_contents): fix a typo. pointed out by wanabe. [ruby-dev:48741] [Bug #10543] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ripper/test_sexp.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48654) +++ ChangeLog (revision 48655) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 30 20:05:55 2014 Nobuyoshi Nakada <nobu@r...> + + * parse.y (regexp_contents): fix a typo. pointed out by wanabe. + [ruby-dev:48741] [Bug #10543] + Sun Nov 30 18:55:32 2014 Tanaka Akira <akr@f...> * test/ruby/test_process.rb (test_deadlock_by_signal_at_forking): Index: parse.y =================================================================== --- parse.y (revision 48654) +++ parse.y (revision 48655) @@ -4261,7 +4261,7 @@ regexp_contents: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L4261 /*% VALUE s1 = 0, s2 = 0, n1 = $1, n2 = $2; if (ripper_is_node_yylval(n1)) { - s1 = RNODE(n2)->nd_cval; + s1 = RNODE(n1)->nd_cval; n1 = RNODE(n1)->nd_rval; } if (ripper_is_node_yylval(n2)) { Index: test/ripper/test_sexp.rb =================================================================== --- test/ripper/test_sexp.rb (revision 48654) +++ test/ripper/test_sexp.rb (revision 48655) @@ -18,4 +18,24 @@ class TestRipper::Sexp < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L18 assert_nil Ripper.sexp("/*/") assert_nil Ripper.sexp("/+/") end + + def test_regexp_content + sexp = Ripper.sexp('//') + assert_nil search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp)) + + sexp = Ripper.sexp('/foo/') + assert_equal 'foo', search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1] + + sexp = Ripper.sexp('/(?<n>a(b|\g<n>))/') + assert_equal '(?<n>a(b|\g<n>))', search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1] + end + + def search_sexp(sym, sexp) + return sexp if !sexp or sexp[0] == sym + sexp.find do |e| + if Array === e and e = search_sexp(sym, e) + return e + end + end + end end if ripper_test -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/