From 30b0fe4cc2dc3489c1105fe41050c0116186e61a Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 1 Jul 2009 06:48:23 +0000 Subject: merge revision(s) 22988: * 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_7@23920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/pathname/test_pathname.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 9b0b9c01e8..f94c123dec 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -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 -- cgit v1.2.3