Commit dddb2bc9 authored by Helga Velroyen's avatar Helga Velroyen Committed by Iustin Pop
Browse files

Annotated inequality operator for unit test properties



This includes:
 * The operator (/=?), which checks for inequality and prints
   an error message if it encounters equality. (Basically the
   negation of the (==?) operator).
 * Application of this operator in the test property
   prop_addPri_NoN1Fail.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 77ffd663
......@@ -138,9 +138,7 @@ prop_addPri_NoN1Fail =
forAll genOnlineNode $ \node ->
forAll (genInstanceSmallerThanNode node) $ \inst ->
let inst' = inst { Instance.mem = Node.fMem node - Node.rMem node }
in case Node.addPri node inst' of
Bad Types.FailN1 -> False
_ -> True
in (Node.addPri node inst' /=? Bad Types.FailN1)
-- | Check that an instance add with too high memory or disk will be
-- rejected.
......
......@@ -80,6 +80,13 @@ maxOpCodes = 16
show x ++ "' /= '" ++ show y ++ "'") (x == y)
infix 3 ==?
-- | Checks for inequality with proper annotation.
(/=?) :: (Show a, Eq a) => a -> a -> Property
(/=?) x y = printTestCase
("Expected inequality, but got equality: '" ++
show x ++ "'.") (x /= y)
infix 3 /=?
-- | Show a message and fail the test.
failTest :: String -> Property
failTest msg = printTestCase msg False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment