我正在尝试(第一次)使用 QuickCheck 来测试一个验证 TCP 端口号的函数:
validatePort :: Int -> Either String Int
validatePort port =
if port > 0 && port <= 65535
then Right port
else Left "Port must be between 1 and 65535 inclusive"
我写了一个这样的任意实例:
instance Arbitrary Int where
arbitrary = choose (1, 65535)
但我不确定如何编写测试属性。