Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 58 lines (48 sloc) 1.747 kb
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
{-# OPTIONS_GHC -Wall #-}
----------------------------------------------------------------------
-- |
-- Module : Main
-- Copyright : (c) Conal Elliott 2008
-- License : BSD3
--
-- Maintainer : conal@conal.net
-- Stability : experimental
--
-- Unamb tests
----------------------------------------------------------------------

module Main where

import Test.QuickCheck.Checkers
import Test.QuickCheck.Later

import Data.Unamb

import System.IO.Unsafe
import Control.Concurrent

main :: IO ()
main = quickBatch batch


batch :: TestBatch
batch = ( "FRP.Reactive.Unamb"
        , [ ("both identity", bothId unambt undefined)
          , ("idempotence" , idempotent2 unambt)
          , ("commutative" , isCommutTimes 0.00001 unambt)
          , ("associative" , isAssocTimes 0.00001 unambt)
          -- These still get tested 500 times. Pointless, but the best I can do on short order. - Svein
          -- TODO: Replace the A/b and B/a tests with something simpler. At the
          -- very least, add a comment here.
          , ("recursive A" , eq b 30)
          , ("recursive B" , eq a 42)
          ]
        )
 where
   -- monomorphic test version
   unambt :: NumT -> NumT -> NumT
   unambt = unamb
   -- For the recursive tests
   x = unsafePerformIO (threadDelay 100000 >> return (42::Int))
   a = unamb x undefined
   b = unamb 30 a

-- On Windows the commutative and associative test take a long time
-- because of the intentional delays. I don't understand the magnitude of
-- the delays, however. They appear to be 1000 times what I'd expect.
-- For instance, 0.00001 sec time 500 tests is 5 milliseconds, but I count
-- about 10 seconds.
--
-- On Linux, everything is zippy.

Something went wrong with that request. Please try again.