From 100253c7f0f4d105ae88340a0314506cde69cfd2 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 2 Dec 2021 10:56:39 +0100 Subject: [ruby/ipaddr] Ipaddr#native must also coerce `@mask_addr` Before it would be left as an IPv6 mask causing `to_range` to fail. ``` >> IPAddr.new("::2").native.to_range /opt/rubies/3.0.3/lib/ruby/3.0.0/ipaddr.rb:479:in `set': invalid address (IPAddr::InvalidAddressError) ``` https://github.com/ruby/ipaddr/commit/af485192f3 --- test/test_ipaddr.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/test_ipaddr.rb') diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb index 2afe749db3..bd163283b2 100644 --- a/test/test_ipaddr.rb +++ b/test/test_ipaddr.rb @@ -360,6 +360,11 @@ class TC_Operator < Test::Unit::TestCase end + def test_native_coerce_mask_addr + assert_equal(IPAddr.new("0.0.0.2/255.255.255.255"), IPAddr.new("::2").native) + assert_equal(IPAddr.new("0.0.0.2/255.255.255.255").to_range, IPAddr.new("::2").native.to_range) + end + def test_loopback? assert_equal(true, IPAddr.new('127.0.0.1').loopback?) assert_equal(true, IPAddr.new('127.127.1.1').loopback?) -- cgit v1.2.1