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 updateLocksWaiting-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 | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/test/hs/Test/Ganeti/Locking/Waiting.hs > b/test/hs/Test/Ganeti/Locking/Waiting.hs > index c7bcf9d..0531035 100644 > --- a/test/hs/Test/Ganeti/Locking/Waiting.hs > +++ b/test/hs/Test/Ganeti/Locking/Waiting.hs > @@ -252,6 +252,23 @@ prop_SimulateUpdateLocks = > , notify == notify' > , extRepr finState == extRepr finState' > ] > +-- | Verify that any state is indistinguishable from its canonical version > +-- (i.e., the one obtained from the extensional representation) with > respect > +-- to updateLocksWaiting. > +prop_SimulateUpdateLocksWaiting :: Property > +prop_SimulateUpdateLocksWaiting = > + forAll (arbitrary :: Gen (LockWaiting TestLock TestOwner Integer)) $ > \state -> > + forAll (arbitrary :: Gen TestOwner) $ \owner -> > + forAll (arbitrary :: Gen Integer) $ \prio -> > + forAll (arbitrary :: Gen [LockRequest TestLock]) $ \req -> > + let state' = fromExtRepr $ extRepr state > + (finState, (result, notify)) = updateLocksWaiting prio owner req > state > + (finState', (result', notify')) = updateLocksWaiting prio 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 > @@ -263,4 +280,5 @@ testSuite "Locking/Waiting" > , 'prop_PendingJustified > , 'prop_extReprPreserved > , 'prop_SimulateUpdateLocks > + , 'prop_SimulateUpdateLocksWaiting > ] > -- > 1.9.1.423.g4596e3a > >
