зеркало из https://github.com/github/ruby.git
remove unnecessary unshift
* ext/pathname/lib/pathname.rb (Pathname#join): remove unnecessary unshift. * test/pathname/test_pathname.rb (TestPathname#test_join): add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
602a9c1416
Коммит
6df5f314ac
|
@ -1,3 +1,10 @@
|
|||
Tue Mar 25 23:32:25 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* ext/pathname/lib/pathname.rb (Pathname#join): remove unnecessary
|
||||
unshift.
|
||||
|
||||
* test/pathname/test_pathname.rb (TestPathname#test_join): add tests.
|
||||
|
||||
Tue Mar 25 16:47:36 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (lex_state_e, parser_params, f_arglist, parser_yylex):
|
||||
|
|
|
@ -384,7 +384,6 @@ class Pathname
|
|||
# #=> true
|
||||
#
|
||||
def join(*args)
|
||||
args.unshift self
|
||||
result = args.pop
|
||||
result = Pathname.new(result) unless Pathname === result
|
||||
return result if result.absolute?
|
||||
|
@ -393,7 +392,7 @@ class Pathname
|
|||
result = arg + result
|
||||
return result if result.absolute?
|
||||
}
|
||||
result
|
||||
self + result
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -234,6 +234,14 @@ class TestPathname < Test::Unit::TestCase
|
|||
def test_join
|
||||
r = Pathname("a").join(Pathname("b"), Pathname("c"))
|
||||
assert_equal(Pathname("a/b/c"), r)
|
||||
r = Pathname("/a").join(Pathname("b"), Pathname("c"))
|
||||
assert_equal(Pathname("/a/b/c"), r)
|
||||
r = Pathname("/a").join(Pathname("/b"), Pathname("c"))
|
||||
assert_equal(Pathname("/b/c"), r)
|
||||
r = Pathname("/a").join(Pathname("/b"), Pathname("/c"))
|
||||
assert_equal(Pathname("/c"), r)
|
||||
r = Pathname("/a").join("/b", "/c")
|
||||
assert_equal(Pathname("/c"), r)
|
||||
end
|
||||
|
||||
def test_absolute
|
||||
|
|
Загрузка…
Ссылка в новой задаче