From: Michael Orlitzky Date: Sun, 23 May 2010 16:52:20 +0000 (-0400) Subject: Update Octet for the new definition of apply_mask. X-Git-Tag: 0.0.1~25 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=b6a453d3584f471b9a729d6df52204f821dda356;p=hath.git Update Octet for the new definition of apply_mask. --- diff --git a/src/Octet.hs b/src/Octet.hs index ceeb4b8..d80b796 100644 --- a/src/Octet.hs +++ b/src/Octet.hs @@ -42,17 +42,17 @@ instance Arbitrary Octet where instance Maskable Octet where - apply_mask _ Maskbits.None = Octet.None - apply_mask Octet.None _ = Octet.None - apply_mask oct mask + apply_mask _ Maskbits.None _ = Octet.None + apply_mask Octet.None _ _ = Octet.None + apply_mask oct mask bit | mask == Eight = oct - | mask == Seven = oct { b8 = B.Zero } - | mask == Six = oct { b8 = B.Zero, b7 = B.Zero } - | mask == Five = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero } - | mask == Four = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero } - | mask == Three = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero } - | mask == Two = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero, b3 = B.Zero } - | mask == Maskbits.One = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero, b3 = B.Zero, b2 = B.Zero } + | mask == Seven = oct { b8 = bit } + | mask == Six = oct { b8 = bit, b7 = bit } + | mask == Five = oct { b8 = bit, b7 = bit, b6 = bit } + | mask == Four = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit } + | mask == Three = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit } + | mask == Two = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit, b3 = bit } + | mask == Maskbits.One = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit, b3 = bit, b2 = bit } | mask == Maskbits.Zero = min_octet | otherwise = Octet.None @@ -116,7 +116,7 @@ test_octet_from_int1 = test_octet_mask1 :: Test test_octet_mask1 = - TestCase $ assertEqual "The network bits of 255/4 should equal 240" oct2 (apply_mask oct1 Four) + TestCase $ assertEqual "The network bits of 255/4 should equal 240" oct2 (apply_mask oct1 Four B.Zero) where oct1 = octet_from_int 255 oct2 = octet_from_int 240 @@ -124,7 +124,7 @@ test_octet_mask1 = test_octet_mask2 :: Test test_octet_mask2 = - TestCase $ assertEqual "The network bits of 255/1 should equal 128" oct2 (apply_mask oct1 Maskbits.One) + TestCase $ assertEqual "The network bits of 255/1 should equal 128" oct2 (apply_mask oct1 Maskbits.One B.Zero) where oct1 = octet_from_int 255 oct2 = octet_from_int 128