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:
parent
1170b057e0
commit
60d4fc9f68
3 changed files with 11 additions and 0 deletions
|
@ -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>
|
Tue Apr 1 11:39:57 2014 James Edward Gray II <james@graysoftinc.com>
|
||||||
|
|
||||||
* lib/csv.rb: Symbol HeaderConverter: strip leading/trailing space.
|
* lib/csv.rb: Symbol HeaderConverter: strip leading/trailing space.
|
||||||
|
|
|
@ -384,6 +384,7 @@ class Pathname
|
||||||
# #=> true
|
# #=> true
|
||||||
#
|
#
|
||||||
def join(*args)
|
def join(*args)
|
||||||
|
return self if args.empty?
|
||||||
result = args.pop
|
result = args.pop
|
||||||
result = Pathname.new(result) unless Pathname === result
|
result = Pathname.new(result) unless Pathname === result
|
||||||
return result if result.absolute?
|
return result if result.absolute?
|
||||||
|
|
|
@ -242,6 +242,8 @@ class TestPathname < Test::Unit::TestCase
|
||||||
assert_equal(Pathname("/c"), r)
|
assert_equal(Pathname("/c"), r)
|
||||||
r = Pathname("/a").join("/b", "/c")
|
r = Pathname("/a").join("/b", "/c")
|
||||||
assert_equal(Pathname("/c"), r)
|
assert_equal(Pathname("/c"), r)
|
||||||
|
r = Pathname("/foo/var").join()
|
||||||
|
assert_equal(Pathname("/foo/var"), r)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_absolute
|
def test_absolute
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue