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

Fix error with empty args.

* ext/pathname/lib/pathname.rb (Pathname#join): Fix error with
  empty args. Reported by ko1 via IRC.

* test/pathname/test_pathname.rb (TestPathname#test_join): Add the
  test for above case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kazu 2014-04-02 02:51:20 +00:00
parent 1170b057e0
commit 60d4fc9f68
3 changed files with 11 additions and 0 deletions

View file

@ -1,3 +1,11 @@
Wed Apr 2 11:46:29 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* ext/pathname/lib/pathname.rb (Pathname#join): Fix error with
empty args. Reported by ko1 via IRC.
* test/pathname/test_pathname.rb (TestPathname#test_join): Add the
test for above case.
Tue Apr 1 11:39:57 2014 James Edward Gray II <james@graysoftinc.com>
* lib/csv.rb: Symbol HeaderConverter: strip leading/trailing space.

View file

@ -384,6 +384,7 @@ class Pathname
# #=> true
#
def join(*args)
return self if args.empty?
result = args.pop
result = Pathname.new(result) unless Pathname === result
return result if result.absolute?

View file

@ -242,6 +242,8 @@ class TestPathname < Test::Unit::TestCase
assert_equal(Pathname("/c"), r)
r = Pathname("/a").join("/b", "/c")
assert_equal(Pathname("/c"), r)
r = Pathname("/foo/var").join()
assert_equal(Pathname("/foo/var"), r)
end
def test_absolute