From 2e4b1b0e58dd6286582a1ecdfee9575abe88f0e8 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 19 Apr 2009 13:33:18 +0000 Subject: merges r22987 from trunk into ruby_1_9_1. -- * lib/pathname.rb (Pathname#sub): set $~ in block.binding. [ruby-dev:38173] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23217 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 da12383bd..c2ce292de 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -392,6 +392,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 -- cgit