1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
{-# LANGUAGE OverloadedStrings #-}
module TestHashECMWithTestSequence (
testWithTestSequence
) where
import Caching.ExpiringCacheMap.HashECM (newECMForM, lookupECM, CacheSettings(..), consistentDuration)
import qualified Caching.ExpiringCacheMap.Utils.TestSequence as TestSeq
import TestECMWithTestSequenceCommon
import qualified Data.ByteString.Char8 as BS
import System.Exit (exitFailure)
testWithTestSequence = do
(TestSeq.TestSequenceState (_, events', _), return_value) <- TestSeq.runTestSequence test'
(TestSeq.TestSequenceState (_, events'', _), return_value) <- TestSeq.runTestSequence test''
(TestSeq.TestSequenceState (_, events''', _), return_value) <- TestSeq.runTestSequence test'''
(TestSeq.TestSequenceState (_, events'''', _), return_value) <- TestSeq.runTestSequence test''''
if pattern' (filt events') &&
pattern'' (filt events'') &&
pattern''' (filt events''') &&
pattern'''' (filt events'''')
then do
putStrLn "Passed TestHashECMWithTestSequence"
-- printOutEvents events' events'' events''' events''''
return ()
else do
printOutFailedPattern "TestHashECMWithTestSequence.testWithTestSequence"
(filt events') (filt events'') (filt events''') (filt events'''')
printOutEvents events' events'' events''' events''''
exitFailure
where
filt = filter someEventsOnly . reverse
commonreadnumber =
(\state _id -> do number <- TestSeq.readNumber
return (state, number))
newTestECM valreq timecheck =
newECMForM valreq
(TestSeq.getCurrentTime >>= return)
timecheck
(CacheWithLRUList 6 6 12)
TestSeq.newTestSVar TestSeq.enterTestSVar TestSeq.readTestSVar
test' = do
filecache <- newTestECM
(consistentDuration 100 commonreadnumber) -- Duration between access and expiry time
12000 -- Time check frequency
testLookups (lookupECM filecache)
test'' = do
filecache <- newTestECM
(consistentDuration 100 commonreadnumber) -- Duration between access and expiry time
1 -- Time check frequency
testLookups (lookupECM filecache)
test''' = do
filecache <- newTestECM
(consistentDuration 1 commonreadnumber) -- Duration between access and expiry time
12000 -- Time check frequency
testLookups (lookupECM filecache)
test'''' = do
filecache <- newTestECM
(consistentDuration 1 commonreadnumber) -- Duration between access and expiry time
1 -- Time check frequency
testLookups (lookupECM filecache)
-- main = testWithTestSequence
|