summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-17 05:26:15 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-17 05:26:15 +0000
commita28532dcf3e237b8d75c724cd65eb04ca57e6da1 (patch)
tree8e8690ef4920c1981fc7749a2f146a9c4f4b4bc4 /test
parent27a39b8ffed0c8317f5d44e21dee52e66ee66e40 (diff)
* lib/pathname.rb (Pathname#sub): set $~ in block.binding.
[ruby-dev:38173] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/pathname/test_pathname.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index d979ff7023..a9f7149633 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -471,6 +471,15 @@ class TestPathname < Test::Unit::TestCase
defassert(:pathsubext, 'fooaa.o', 'fooaa', '.o')
defassert(:pathsubext, 'd.e/aa.o', 'd.e/aa', '.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