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

* lib/pathname.rb (Pathname#sub): set $~ in block.binding.

[ruby-dev:38173]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-03-17 05:56:59 +00:00
parent 127a23f3ed
commit d6c77c9647
3 changed files with 29 additions and 1 deletions

View file

@ -381,6 +381,15 @@ class TestPathname < Test::Unit::TestCase
def pathsub(path, pat, repl) Pathname.new(path).sub(pat, repl).to_s end
defassert(:pathsub, "a.o", "a.c", /\.c\z/, ".o")
def test_sub_matchdata
result = Pathname("abc.gif").sub(/\..*/) {
assert_not_nil($~)
assert_equal(".gif", $~[0])
".png"
}
assert_equal("abc.png", result.to_s)
end
def root?(path)
Pathname.new(path).root?
end