Revision 20bc5360 htest/Test/Ganeti/OpCodes.hs
b/htest/Test/Ganeti/OpCodes.hs | ||
---|---|---|
73 | 73 |
-- * Test cases |
74 | 74 |
|
75 | 75 |
-- | Check that opcode serialization is idempotent. |
76 |
prop_OpCodes_serialization :: OpCodes.OpCode -> Property
|
|
77 |
prop_OpCodes_serialization op =
|
|
76 |
prop_serialization :: OpCodes.OpCode -> Property |
|
77 |
prop_serialization op = |
|
78 | 78 |
case J.readJSON (J.showJSON op) of |
79 | 79 |
J.Error e -> failTest $ "Cannot deserialise: " ++ e |
80 | 80 |
J.Ok op' -> op ==? op' |
81 | 81 |
|
82 | 82 |
-- | Check that Python and Haskell defined the same opcode list. |
83 |
case_OpCodes_AllDefined :: HUnit.Assertion
|
|
84 |
case_OpCodes_AllDefined = do
|
|
83 |
case_AllDefined :: HUnit.Assertion |
|
84 |
case_AllDefined = do |
|
85 | 85 |
py_stdout <- runPython "from ganeti import opcodes\n\ |
86 | 86 |
\print '\\n'.join(opcodes.OP_MAPPING.keys())" "" >>= |
87 | 87 |
checkPythonResult |
... | ... | |
111 | 111 |
-- a better way to do this, for example by having a |
112 | 112 |
-- separately-launched Python process (if not running the tests would |
113 | 113 |
-- be skipped). |
114 |
case_OpCodes_py_compat :: HUnit.Assertion
|
|
115 |
case_OpCodes_py_compat = do
|
|
114 |
case_py_compat :: HUnit.Assertion |
|
115 |
case_py_compat = do |
|
116 | 116 |
let num_opcodes = length OpCodes.allOpIDs * 500 |
117 | 117 |
sample_opcodes <- sample' (vectorOf num_opcodes |
118 | 118 |
(arbitrary::Gen OpCodes.OpCode)) |
... | ... | |
143 | 143 |
) $ zip opcodes decoded |
144 | 144 |
|
145 | 145 |
testSuite "OpCodes" |
146 |
[ 'prop_OpCodes_serialization
|
|
147 |
, 'case_OpCodes_AllDefined
|
|
148 |
, 'case_OpCodes_py_compat
|
|
146 |
[ 'prop_serialization |
|
147 |
, 'case_AllDefined |
|
148 |
, 'case_py_compat |
|
149 | 149 |
] |
Also available in: Unified diff