mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 06:25:31 +02:00
parse.y: fix a typo
* parse.y (regexp_contents): fix a typo. pointed out by wanabe. [ruby-dev:48741] [Bug #10543] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1918ea16c7
commit
d40aad1c09
3 changed files with 26 additions and 1 deletions
|
@ -18,4 +18,24 @@ class TestRipper::Sexp < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue