{- Copyright (C) 2010 Andrejs Sisojevs All rights reserved. For license and copyright information, see the file COPYRIGHT -} -------------------------------------------------------------------------- -------------------------------------------------------------------------- import Data.EmptySet import Data.NeverEmptyList import Data.CardinalityRange import Data.Map import Control.Monad import Control.Monad.Identity instance Eq a => Eq (Identity a) where a == b = runIdentity a == runIdentity b instance Show a => Show (Identity a) where show i_a = "Identity " ++ show (runIdentity i_a) test_set :: [(Int, Bool)] test_set = [ (10, ((sContTransT []) :: Maybe (Maybe Int)) == Just Nothing) , (20, ((sContTrans ()) :: Maybe (Maybe Int)) == Just Nothing) , (30, ((sContTransT [1]) :: (Maybe (Maybe Int))) == Just (Just 1)) , (40, ((sContTransT [1, 2]) :: (Maybe (Maybe Int))) == Nothing) , (50, ((sContTransT $ Just "Hello") :: (Maybe (Identity String))) == Just (Identity "Hello")) , (60, ((sContTransT ["Hello"]) :: Maybe (Identity String)) == Just (Identity "Hello")) , (70, ((sContTransT (EmptySet :: EmptySet String)) :: (Maybe [String])) == Just []) , (80, ((sContTransT "Hello") :: Maybe (EmptySet Char)) == Nothing) , (90, ((sContTransT ("key", "elem")) :: Maybe (Map String String)) == Just (singleton "key" "elem")) , (100, ((sContTrans [("key1", "elem1"), ("key2", "elem2")]) :: Maybe (Map String String)) == Just (fromList [("key1", "elem1"), ("key2", "elem2")])) , (110, ((sContTrans (EmptySet :: EmptySet (String, String))) :: Maybe (Map String String)) == Just empty) , (120, ((sContTrans []) :: Maybe ()) == Just ()) , (130, ((sContTrans (NEL 'H' "i!")) :: Maybe String) == Just "Hi!") -- Data.NeverEmptyList , (140, ((sContTrans ()) :: Maybe String) == Just "") , (150, ((sContTrans "") :: Maybe (Identity Char)) == Nothing) , (160, ((sContTrans "Hi!") :: Maybe ()) == Nothing) ] main = do putStrLn ("INDEX) IS_VALID | TEST_CASE\n------------------------------") flip mapM_ test_set (\ (idx, _case) -> putStrLn (show idx ++ ") " ++ show _case))