mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/pathname.rb (Pathname#initialize): fix pathname initialization
by pathname. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8b33b47ea0
commit
2546a366ed
2 changed files with 14 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu May 27 21:37:50 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* lib/pathname.rb (Pathname#initialize): refine pathname initialization
|
||||||
|
by pathname.
|
||||||
|
|
||||||
Thu May 27 20:22:05 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
Thu May 27 20:22:05 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
* io.c (rb_io_fwrite): check all case errno != 0 [ruby-dev:23648]
|
* io.c (rb_io_fwrite): check all case errno != 0 [ruby-dev:23648]
|
||||||
|
|
|
@ -185,7 +185,8 @@ class Pathname
|
||||||
# If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
|
# If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
|
||||||
#
|
#
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@path = path.to_str.dup
|
path = path.to_str if path.respond_to? :to_str
|
||||||
|
@path = path.dup
|
||||||
|
|
||||||
if /\0/ =~ @path
|
if /\0/ =~ @path
|
||||||
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
|
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
|
||||||
|
@ -882,6 +883,13 @@ if $0 == __FILE__
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
class PathnameTest < Test::Unit::TestCase # :nodoc:
|
class PathnameTest < Test::Unit::TestCase # :nodoc:
|
||||||
|
def test_initialize
|
||||||
|
p1 = Pathname.new('a')
|
||||||
|
assert_equal('a', p1.to_s)
|
||||||
|
p2 = Pathname.new(p1)
|
||||||
|
assert_equal(p1, p2)
|
||||||
|
end
|
||||||
|
|
||||||
class AnotherStringLike # :nodoc:
|
class AnotherStringLike # :nodoc:
|
||||||
def initialize(s) @s = s end
|
def initialize(s) @s = s end
|
||||||
def to_str() @s end
|
def to_str() @s end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue