LGTM

On Wed, Apr 9, 2014 at 9:06 PM, Klaus Aehlig <[email protected]> wrote:

> Add a test that verifies that extRepr-equal states cannot be
> distinguished by updateLocks-transitions. To obtain extRepr-equal
> states, we compare each state to the one computed from its
> extensional representation.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  test/hs/Test/Ganeti/Locking/Waiting.hs | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/test/hs/Test/Ganeti/Locking/Waiting.hs
> b/test/hs/Test/Ganeti/Locking/Waiting.hs
> index 26cced3..c7bcf9d 100644
> --- a/test/hs/Test/Ganeti/Locking/Waiting.hs
> +++ b/test/hs/Test/Ganeti/Locking/Waiting.hs
> @@ -236,6 +236,22 @@ prop_extReprPreserved =
>                     \ must have the same extensional representation"
>       $ rep' == rep
>
> +-- | Verify that any state is indistinguishable from its canonical version
> +-- (i.e., the one obtained from the extensional representation) with
> respect
> +-- to updateLocks.
> +prop_SimulateUpdateLocks :: Property
> +prop_SimulateUpdateLocks =
> +  forAll (arbitrary :: Gen (LockWaiting TestLock TestOwner Integer)) $
> \state ->
> +  forAll (arbitrary :: Gen TestOwner) $ \owner ->
> +  forAll (arbitrary :: Gen [LockRequest TestLock]) $ \req ->
> +  let state' = fromExtRepr $ extRepr state
> +      (finState, (result, notify)) = updateLocks owner req state
> +      (finState', (result', notify')) = updateLocks owner req state'
> +  in printTestCase "extRepr-equal states must behave equal on updateLocks"
> +     $ and [ result == result'
> +           , notify == notify'
> +           , extRepr finState == extRepr finState'
> +           ]
>
>  testSuite "Locking/Waiting"
>   [ 'prop_NoActionWithPendingRequests
> @@ -246,4 +262,5 @@ testSuite "Locking/Waiting"
>   , 'prop_ProgressSound
>   , 'prop_PendingJustified
>   , 'prop_extReprPreserved
> + , 'prop_SimulateUpdateLocks
>   ]
> --
> 1.9.1.423.g4596e3a
>
>

Reply via email to