summaryrefslogtreecommitdiff
path: root/test/pathname/test_pathname.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/pathname/test_pathname.rb')
-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 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