mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 20:21:51 -07:00
added new test-suite
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
|
||||
-------------------------------------
|
||||
--
|
||||
-- Tests for XPrompt and ShellPrompt
|
||||
@@ -6,33 +7,18 @@
|
||||
-------------------------------------
|
||||
module XPrompt where
|
||||
|
||||
import Data.Char
|
||||
import Test.QuickCheck
|
||||
|
||||
import Data.List
|
||||
|
||||
import XMonad.Prompt
|
||||
import qualified XMonad.Prompt.Shell as S
|
||||
import Properties
|
||||
|
||||
{-
|
||||
instance Arbitrary Char where
|
||||
arbitrary = choose ('\32', '\255')
|
||||
coarbitrary c = variant (ord c `rem` 4)
|
||||
|
||||
-}
|
||||
|
||||
doubleCheck p = check (defaultConfig { configMaxTest = 1000}) p
|
||||
deepCheck p = check (defaultConfig { configMaxTest = 10000}) p
|
||||
deepestCheck p = check (defaultConfig { configMaxTest = 100000}) p
|
||||
|
||||
-- brute force check for exceptions
|
||||
prop_split (str :: [Char]) =
|
||||
prop_split (str :: String) =
|
||||
forAll (elements str) $ \e -> S.split e str == S.split e str
|
||||
|
||||
-- check if the first element of the new list is indeed the first part
|
||||
-- of the string.
|
||||
prop_spliInSubListsAt (x :: Int) (str :: [Char]) =
|
||||
prop_spliInSubListsAt (x :: Int) (str :: String) =
|
||||
x < length str ==> result == take x str
|
||||
where result = case splitInSubListsAt x str of
|
||||
[] -> []
|
||||
@@ -41,14 +27,14 @@ prop_spliInSubListsAt (x :: Int) (str :: [Char]) =
|
||||
-- skipLastWord is complementary to getLastWord, unless the only space
|
||||
-- in the string is the final character, in which case skipLastWord
|
||||
-- and getLastWord will produce the same result.
|
||||
prop_skipGetLastWord (str :: [Char]) =
|
||||
prop_skipGetLastWord (str :: String) =
|
||||
skipLastWord str ++ getLastWord str == str || skipLastWord str == getLastWord str
|
||||
|
||||
|
||||
-- newIndex and newCommand get only non empy lists
|
||||
elemGen :: Gen ([String],String)
|
||||
elemGen = do
|
||||
a <- arbitrary :: Gen [[Char]]
|
||||
a <- arbitrary :: Gen [String]
|
||||
let l = case filter (/= []) a of
|
||||
[] -> ["a"]
|
||||
x -> x
|
||||
@@ -67,15 +53,6 @@ prop_newIndex_range =
|
||||
-- this is actually the definition of newCommand...
|
||||
-- just to check something.
|
||||
{-
|
||||
prop_newCommandIndex =
|
||||
prop_newCommandIndex =
|
||||
forAll elemGen $ \(l,c) -> (skipLastWord c ++ (l !! (newIndex c l))) == newCommand c l
|
||||
-}
|
||||
|
||||
main = do
|
||||
putStrLn "Testing ShellPrompt.split"
|
||||
deepCheck prop_split
|
||||
putStrLn "Testing spliInSubListsAt"
|
||||
deepCheck prop_spliInSubListsAt
|
||||
putStrLn "Testing skip + get lastWord"
|
||||
deepCheck prop_skipGetLastWord
|
||||
|
||||
|
Reference in New Issue
Block a user