InteractiveTests.hs revision 3db72cc30ef0b59b3d2f6d75705a809f3ce6d8c5
f4505a64a089693012a3f5c3b1f12a82cd7a2a5aKlaus Luettich{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
c63ebf815c8a874525cf18670ad74847f7fc7b26Christian MaederModule : $Header$
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian MaederDescription : Test environment for CSL
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan PascanuCopyright : (c) Ewaryst Schulz, DFKI Bremen 2010
75a6279dbae159d018ef812185416cf6df386c10Till MossakowskiLicense : GPLv2 or higher, see LICENSE.txt
75a6279dbae159d018ef812185416cf6df386c10Till MossakowskiMaintainer : Ewaryst.Schulz@dfki.de
75a6279dbae159d018ef812185416cf6df386c10Till MossakowskiStability : experimental
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian MaederPortability : non-portable (uses type-expression in type contexts)
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian MaederThis file is for experimenting with the Interpreter instances
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maederand general static analysis tools
fa388aea9cef5f9734fec346159899a74432ce26Christian Maederimport CSL.Parse_AS_Basic (parseResult, extparam, pComma, pSemi)
cfaa17b0d2ed0a663f0a4f18b23f98ab876c2f40Christian Maederimport Common.Utils (getEnvDef)
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian Maederimport Common.Result (diags, printDiags, resultToMaybe)
5b50a0fb9834540caf04471389df975fbd356ca3Razvan Pascanu-- the process communication interface
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanuimport qualified Interfaces.Process as PC
66a774f13272fde036481edd2298081ab3d04678Razvan Pascanu-- README: In order to work correctly link the Test.hs in the Hets-root dir to Main.hs (ln -s Test.hs Main.hs)
f66fcd981f556c238df7dd6dfa42123745e3b1d2Christian Maederimport Main (getSigSens)
dda5ab793f1615c1ba1dcaa97a4346b0878da6b1Christian Maederimport Control.Monad.State (StateT(..))
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederimport Data.Maybe (fromJust, fromMaybe)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederimport qualified Data.Map as Map
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- ----------------------------------------------------------------------
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- * general test functions
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- ----------------------------------------------------------------------
8955ea64c61a6e8b96b7696021863afd1a75f6daRazvan Pascanu [ (44, ("/CSL/EN1591.het", "EN1591"))
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederl1 :: Int -> IO (Sign, [(String, CMD)])
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu let (lb, sp) = fromMaybe ("/CSL/Tests.het", "Test" ++ show i)
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu hlib <- getEnvDef "HETS_LIB" $ error "Missing HETS_LIB environment variable"
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu getSigSens CSL (hlib ++ lb) sp
ee1c7c5796832536932d7b06cbfb1ca13f9a0d7bMartin Kühlsig :: Int -> IO Sign
ee1c7c5796832536932d7b06cbfb1ca13f9a0d7bMartin Kühlsig = fmap fst . l1
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- Check if the order is broken or not!
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maedersens :: Int -> IO [(String, CMD)]
c0c2380bced8159ff0297ece14eba948bd236471Christian Maedersens = fmap snd . l1
c0c2380bced8159ff0297ece14eba948bd236471Christian Maedercmds :: Int -> IO [CMD]
fa388aea9cef5f9734fec346159899a74432ce26Christian Maedercmds = fmap (map snd) . sens
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- time measurement, pendant of the time shell command
fa388aea9cef5f9734fec346159899a74432ce26Christian Maedertime :: IO a -> IO a
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder t <- getCurrentTime
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder t' <- getCurrentTime
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder putStrLn $ show $ diffUTCTime t' t
f77f29e84b3f6e791c82e61b13fbf76582bedd2fChristian Maeder-- ----------------------------------------------------------------------
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- * calculator test functions
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder-- ----------------------------------------------------------------------
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederrunTest :: ResultT (IOS b) a -> b -> IO a
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederrunTest cmd r = fmap fromJust $ runTestM cmd r
f77f29e84b3f6e791c82e61b13fbf76582bedd2fChristian MaederrunTestM :: ResultT (IOS b) a -> b -> IO (Maybe a)
toEP inp = case runParser (Lexer.separatedBy extparam pComma >-> fst) "" "" inp of
(Lexer.separatedBy extparam pComma >-> fst) pSemi >-> fst) "" "" inp of
compareEPgen :: Show a => (String -> a) -> (a -> a -> EPCompare) -> String -> String -> IO EPCompare
-- many instances (connection/disconnection tests)
printDiags (PC.verbosity $ getRI r') (diags res)
--s -> t -> t1 -> IO (Common.Result.Result a, s)
y <- fmap fromJust $ runTest (CSL.Interpreter.lookup "y") r'
addOp mp s = Map.insertWith (+) s 1 mp
extractOps :: OpExtractor a => a -> Map.Map String Int
extractOps = extr Map.empty
-- addOp mp s = Map.insertWith (+) s 1 mp
-- extractOps :: OpExtractor a => a -> Map.Map String Int
-- extractOps = extr Map.empty