[前][次][番号順一覧][スレッド一覧]

ruby-changes:33420

From: kazu <ko1@a...>
Date: Wed, 2 Apr 2014 11:51:26 +0900 (JST)
Subject: [ruby-changes:33420] kazu:r45499 (trunk): Fix error with empty args.

kazu	2014-04-02 11:51:20 +0900 (Wed, 02 Apr 2014)

  New Revision: 45499

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45499

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/pathname/lib/pathname.rb
    trunk/test/pathname/test_pathname.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45498)
+++ ChangeLog	(revision 45499)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Apr  2 11:46:29 2014  Kazuhiro NISHIYAMA  <zn@m...>
+
+	* 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@g...>
 
 	* lib/csv.rb: Symbol HeaderConverter: strip leading/trailing space.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 45498)
+++ ext/pathname/lib/pathname.rb	(revision 45499)
@@ -384,6 +384,7 @@ class Pathname https://github.com/ruby/ruby/blob/trunk/ext/pathname/lib/pathname.rb#L384
   #       #=> true
   #
   def join(*args)
+    return self if args.empty?
     result = args.pop
     result = Pathname.new(result) unless Pathname === result
     return result if result.absolute?
Index: test/pathname/test_pathname.rb
===================================================================
--- test/pathname/test_pathname.rb	(revision 45498)
+++ test/pathname/test_pathname.rb	(revision 45499)
@@ -242,6 +242,8 @@ class TestPathname < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L242
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]