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

* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.

(Resolv::DNS::Name#initialize): Normalize labels as
  Resolv::DNS::Label::Str objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2015-01-02 00:10:04 +00:00
parent 31d24fae56
commit ec7f1f5dc2
3 changed files with 22 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Fri Jan 2 09:08:31 2015 Tanaka Akira <akr@fsij.org>
* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
(Resolv::DNS::Name#initialize): Normalize labels as
Resolv::DNS::Label::Str objects.
Thu Jan 1 21:41:49 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* doc/regexp.rdoc: fix regexp docs for whitespace character.

View file

@ -1185,7 +1185,7 @@ class Resolv
end
def ==(other)
return @downcase == other.downcase
return self.class == other.class && @downcase == other.downcase
end
def eql?(other)
@ -1221,6 +1221,14 @@ class Resolv
end
def initialize(labels, absolute=true) # :nodoc:
labels = labels.map {|label|
case label
when String then Label::Str.new(label)
when Label::Str then label
else
raise ArgumentError, "unexpected label: #{label.inspect}"
end
}
@labels = labels
@absolute = absolute
end

View file

@ -190,4 +190,11 @@ class TestResolvDNS < Test::Unit::TestCase
upper = Resolv::DNS::Name.create("Ruby-Lang.org")
assert_equal(lower, upper, bug10550)
end
def test_ipv6_name
addr = Resolv::IPv6.new("\0"*16)
labels = addr.to_name.to_a
expected = (['0'] * 32 + ['ip6', 'arpa']).map {|label| Resolv::DNS::Label::Str.new(label) }
assert_equal(expected, labels)
end
end