| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
TestHarness
Synopsis
- allowFailures :: Int -> [Test] -> Assertion
- callTo :: String -> Module SrcSpanInfo -> Decl SrcSpanInfo -> Bool
- contains :: (Typeable b, Data a) => (b -> Bool) -> a -> Bool
- declName :: Decl SrcSpanInfo -> String
- doNotation :: Exp SrcSpanInfo -> Bool
- rhsContains :: (Typeable b, Data a) => (b -> Bool) -> a -> Bool
- findDecls :: Data a => a -> [Decl SrcSpanInfo]
- findDeclsCalling :: Data a => String -> a -> [String]
- findTopLevelDeclsOf :: String -> Module SrcSpanInfo -> [Decl SrcSpanInfo]
- globallySelfRecursive :: Module SrcSpanInfo -> Decl SrcSpanInfo -> Bool
- ident :: String -> Name SrcSpanInfo -> Bool
- listComprehension :: Exp SrcSpanInfo -> Bool
- locallySelfRecursive :: Decl SrcSpanInfo -> Bool
- randomChoice :: [a] -> IO a
- run :: Testable t => [t] -> IO (Counts, ShowS)
- syntaxCheck :: (Module SrcSpanInfo -> Assertion) -> Assertion
- syntaxCheckWithExts :: [String] -> (Module SrcSpanInfo -> Assertion) -> Assertion
- typeSignatureOf :: String -> Decl SrcSpanInfo -> Bool
Documentation
allowFailures :: Int -> [Test] -> Assertion Source #
Detailed output of correct/incorrect Tests in case of failure with the option to allow a fixed number of tests to fail.
callTo :: String -> Module SrcSpanInfo -> Decl SrcSpanInfo -> Bool Source #
True if name appears directly or indirectly in the declaration, considering the entire module.
Used to detect if student code contains required exercise components
when AllowAdding is set to True.
contains :: (Typeable b, Data a) => (b -> Bool) -> a -> Bool Source #
Search a structure for a node satisfying some predicate. Use case: scan submission code syntax tree.
Also matches the left hand side of function definitions, so cannot be used to check if a function calls itself.
This will also match explicit imports
when searching for an identifier in the overall module via ident.
doNotation :: Exp SrcSpanInfo -> Bool Source #
True if expression is a do block.
rhsContains :: (Typeable b, Data a) => (b -> Bool) -> a -> Bool Source #
Same as contains, but only considers the right hand side of equations.
Can therefore be used to check for self recursion and avoids overlap with imports.
findDecls :: Data a => a -> [Decl SrcSpanInfo] Source #
Query a syntax tree for all declarations and constants. This includes let and where bindings.
findDeclsCalling :: Data a => String -> a -> [String] Source #
Query a syntax tree for all declaration names containing the given name. This also takes indirecting bindings into account.
findTopLevelDeclsOf :: String -> Module SrcSpanInfo -> [Decl SrcSpanInfo] Source #
Query a module's syntax tree for all top level function declarations and constants.
globallySelfRecursive :: Module SrcSpanInfo -> Decl SrcSpanInfo -> Bool Source #
True if declaration is defined recursively, taking the entire module into account.
This returns a false positive if a binding in a righthand side uses the definition's name but goes unused.
listComprehension :: Exp SrcSpanInfo -> Bool Source #
True if expression is a list comprehension.
locallySelfRecursive :: Decl SrcSpanInfo -> Bool Source #
True if declaration is defined recursively,
but only if the recursion is stated in the righthand side of the equation.
Recursion through indirection, e.g. via a chain of global definitions is not detected.
This is usually sufficient if allowAdding is set to False.
This returns a false positive if a binding in the righthand side uses the definition's name but goes unused.
randomChoice :: [a] -> IO a Source #
run :: Testable t => [t] -> IO (Counts, ShowS) Source #
Function called by the interpreter, getting the tests to run as the argument.
syntaxCheck :: (Module SrcSpanInfo -> Assertion) -> Assertion Source #
Run an assertion on the submission module's syntax tree.
Only enables language extensions explicitly listed in the student's submission file. Using any hidden default extensions will cause a parse error.
syntaxCheckWithExts :: [String] -> (Module SrcSpanInfo -> Assertion) -> Assertion Source #
Same as syntaxCheck, but takes a list of extensions to enable
on top of what is found in the file.
typeSignatureOf :: String -> Decl SrcSpanInfo -> Bool Source #
True if declaration is a type signature of the given function name.