aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_ipaddr.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 13:53:38 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 13:53:38 +0000
commit2d8841791facb07155c710d8a7db7b0bf8be0d21 (patch)
tree050e10063c3ceff4fecaeaec4c333fe497e4d6cb /test/test_ipaddr.rb
parent9cbd6ee09770be3d73a17ab1195a094c59c9f9ee (diff)
downloadruby-2d8841791facb07155c710d8a7db7b0bf8be0d21.tar.gz
IPAddr#== and IPAddr#<=> no longer raise an exception if coercion fails
* lib/ipaddr.rb (IPAddr#==): If coercion fails, return false instead of passing through the exception. [ruby-core:77451] [Bug #12799] * lib/ipaddr.rb (IPAddr#<=>): If coercion fails, return nil instead of passing through the exception. [ruby-core:77451] [Bug #12799] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_ipaddr.rb')
-rw-r--r--test/test_ipaddr.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb
index b9209f72d9..86482a08bd 100644
--- a/test/test_ipaddr.rb
+++ b/test/test_ipaddr.rb
@@ -169,6 +169,8 @@ class TC_Operator < Test::Unit::TestCase
@a = IPAddr.new("3ffe:505:2::/48")
@b = IPAddr.new("0:0:0:1::")
@c = IPAddr.new(IN6MASK32)
+ @inconvertible_range = 1..5
+ @inconvertible_string = "sometext"
end
alias set_up setup
@@ -220,6 +222,13 @@ class TC_Operator < Test::Unit::TestCase
assert_equal(false, @a == IPAddr.new("3ffe:505:3::"))
assert_equal(true, @a != IPAddr.new("3ffe:505:3::"))
assert_equal(false, @a != IPAddr.new("3ffe:505:2::"))
+ assert_equal(false, @a == @inconvertible_range)
+ assert_equal(false, @a == @inconvertible_string)
+ end
+
+ def test_compare
+ assert_equal(nil, @a <=> @inconvertible_range)
+ assert_equal(nil, @a <=> @inconvertible_string)
end
def test_mask