mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
This is a convenience module in order to have less import noise. It re-exports the following: a) Commonly used modules in full (Data.Foldable, Data.Applicative, and so on); though only those that play nicely with each other, so that XMonad.Prelude can be imported unqualified without any problems. This prevents things like `Prelude.(.)` and `Control.Category.(.)` fighting with each other. b) Helper functions that don't necessarily fit in any other module; e.g., the often used abbreviation `fi = fromIntegral`.
60 lines
1.8 KiB
Haskell
60 lines
1.8 KiB
Haskell
{-# LANGUAGE ScopedTypeVariables #-}
|
|
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
|
|
-------------------------------------
|
|
--
|
|
-- Tests for XPrompt and ShellPrompt
|
|
--
|
|
-------------------------------------
|
|
module XPrompt where
|
|
|
|
import Test.QuickCheck
|
|
|
|
import XMonad.Prelude (chunksOf)
|
|
import XMonad.Prompt
|
|
import qualified XMonad.Prompt.Shell as S
|
|
|
|
-- brute force check for exceptions
|
|
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 :: String) =
|
|
x < length str ==> result == take x str
|
|
where result = case chunksOf x str of
|
|
[] -> []
|
|
x -> head x
|
|
|
|
-- 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 :: 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 [String]
|
|
let l = case filter (/= []) a of
|
|
[] -> ["a"]
|
|
x -> x
|
|
e <- elements l
|
|
return (l,e)
|
|
|
|
{- newIndex and newCommand have since been renamed or are no longer used
|
|
|
|
-- newIndex calculates the index of the next completion in the
|
|
-- completion list, so the index must be within the range of the
|
|
-- copletions list
|
|
prop_newIndex_range =
|
|
forAll elemGen $ \(l,c) -> newIndex c l >= 0 && newIndex c l < length l
|
|
-}
|
|
|
|
-- this is actually the definition of newCommand...
|
|
-- just to check something.
|
|
{-
|
|
prop_newCommandIndex =
|
|
forAll elemGen $ \(l,c) -> (skipLastWord c ++ (l !! (newIndex c l))) == newCommand c l
|
|
-}
|