summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-30 11:05:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-30 11:05:58 +0000
commitd40aad1c09e509e585a8f23a2e713048ad5f3384 (patch)
tree7ca7450e19cec27e6bda08eaa3525002449c8088 /test/ripper
parent1918ea16c788e6fcca468f4223bb24bb8b358f22 (diff)
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
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_sexp.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb
index 9be4aa7..adf8c46 100644
--- a/test/ripper/test_sexp.rb
+++ b/test/ripper/test_sexp.rb
@@ -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