File: AutoUpdateSpec.hs

package info (click to toggle)
haskell-auto-update 0.1.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 112 kB
  • sloc: haskell: 373; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 981 bytes parent folder | download | duplicates (3)
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
module Control.AutoUpdateSpec (spec) where

import Control.AutoUpdate
import Control.Concurrent (threadDelay)
import Control.Monad (replicateM_, forM_)
import Data.IORef
import Test.Hspec
import Test.Hspec.QuickCheck

spec :: Spec
spec = return ()
  -- do
  --   prop "incrementer" $ \st' -> do
  --       let st = abs st' `mod` 10000
  --       ref <- newIORef 0
  --       next <- mkAutoUpdate defaultUpdateSettings
  --           { updateAction = atomicModifyIORef ref $ \i ->
  --               let i' = succ i in i' `seq` (i', i')
  --           , updateSpawnThreshold = st
  --           , updateFreq = 10000
  --           }

  --       forM_ [1..st + 1] $ \i -> do
  --           j <- next
  --           j `shouldBe` i

  --       replicateM_ 50 $ do
  --           i <- next
  --           i `shouldBe` st + 2

  --       threadDelay 60000
  --       last1 <- readIORef ref
  --       threadDelay 20000
  --       last2 <- readIORef ref
  --       last2 `shouldBe` last1