TestExplode-0.1.0.0: Generates testcases from program-snippets

Copyright(c) Hans-Jürgen Guth, 2014
LicenseLGPL
Maintainerjuergen.software@freea2a.de
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

TestExplode.TestExplode

Contents

Description

With this module you can define a graph of part-testcases (Casepart) and evaluate this graph to a list of strings, where every string is the concatenation of the code of the part-testcases.

Synopsis

Types

data Casepart cnf locals Source

The part-testcase

Constructors

Casepart 

Fields

shortDesc :: Text

short description of the part-testcase, currently used a) at top of a testcase to show which path the generated testcase belongs to and b) in the visualised graph as node-label

longDesc :: Text

long description of the part-testcase currently generated in front of the code of the part-testcase

condDesc :: Text

description of the condition, under which the part-testcase is valid (if not, the path with this part-testcase will not be generated)

codeFkt :: cnf -> locals -> Text

the actual code, which forms the part-testcase, dependent of the "configuration" (the "cnf" in 'Casepart cnf locals'), which is the test-data, and local variables, that are changed by a Casepart.

varFkt :: cnf -> locals -> locals

The changes in the local variables

condition :: cnf -> locals -> Bool

the condition under which the part-testcase is valid (if not, the path with this part-testcase will not be generated)

cpType :: CPType

Type of the Casepart, mainly (up to now only) for visualisation in the graph of Caseparts

data CasepartInternal cnf locals Source

The part-testcase, internal format of Casepart, with a writer-monad as stringFkt instead of the varFkt and the old stringFkt

Constructors

CasepartInternal 

Fields

shortDescI :: Text
 
longDescI :: Text
 
condDescI :: Text
 
codeFktI :: cnf -> locals -> Writer (Seq Text) locals
 
conditionI :: cnf -> locals -> Bool
 
cpTypeI :: CPType
 

data CPType Source

Types of Caseparts, mainly (up to now only) for visualisation of the graph of Caseparts

Constructors

NormalCP 
Mark 

Instances

data DirGraph a Source

Directed graph with one end, self-invented definition

Constructors

SimpleDG a

Constructor for a node alone, A node is a graph.

Conc (DirGraph a) (DirGraph a)

Constructor for one sub-graph after another

Join (SplittedGraph a)

Constructor for the "splitting" of graphs, comparable with an "if". The Join makes the many ends and begins to one end and one begin

StructDG (Testgraph a)

A graph with more attributes, importing of a Testgraph, only the part dirGraph is used

data SplittedGraph a Source

many disjunct graphs Every part-graph has one end and one begin

Constructors

Split [DirGraph a] 

data Testgraph a Source

Constructors

Testgraph 

data Expand Source

Constructors

Expand 
NotExpand 
AsIs 

Functions

generate Source

Arguments

:: Text

how a text is coomented, ("# " or "-- ")

-> [cnf]

a list of the testvalues

-> locals

the initial value of the variables that the testcases change

-> (cnf -> Text)

"prelude" of a testcase, i.e. show of cnf

-> DirGraph (CasepartInternal cnf locals)

the graph of caseparts

-> [Text]

the final result: the list of testcases incl. comments

The heart of this module, the final function. It takes configurations (cnf means testvalues), that is a record of variables with a value, a function that describes the "prelude" of one testcase (without comment chars, which are later added) (a good starting value : the show-function of cnf, so that the used test-values are printed on top of the testcase), the graph of testcases and returns

voilá:

the list of testcases, ready to printed out in seperate files and to run.

emptyCp :: Casepart cnf locals Source

An empty testcase, all strings are "". The condition is always True. Shall serve as an starting point for own definitions of Casepart's.

markCp :: Text -> Casepart cnf locals Source

Convenience Function to make easily a mark.

getSubGraphs :: DirGraph a -> [(String, Testgraph a)] -> [(String, Testgraph a)] Source

Looks for all embedded Testgraph in a DirGraph, double embedded Testgraph (identified by the attribute name) are ignored.

Functions for generating DirGraph s

mkEle :: Casepart cnf locals -> DirGraph (CasepartInternal cnf locals) Source

Function to create a node, function for the user. If longDesc = "", shortDesc is used as longDesc.

(&-&) :: DirGraph a -> DirGraph a -> DirGraph a Source

Infix synonym for conc

conc :: DirGraph a -> DirGraph a -> DirGraph a Source

Function to craete a Conc of two sub-graphs

split :: [DirGraph a] -> DirGraph a Source

Function to create a splitted graph

mkGraph2Ele Source

Arguments

:: (cnfNew -> cnfOld)

conversion function for the test-data-input of the casepart

-> (localsInB -> localsInA)

conversion function for the variables the testcases uses/changes (input-side)

-> (localsInB -> localsInA -> localsInB)

conversion function for the variables the testcases uses/changes (output-side) that is: how shall the variables look after the run of the casepart? Dependant of the old value of the variables and the value of the variables after run of the imported testcase

-> Expand

Shall this Graph in the documation expanded or not ?

-> Testgraph (CasepartInternal cnfOld localsInA)

the Testgraph that shall be imported

-> DirGraph (CasepartInternal cnfNew localsInB)

the imported Testgraph, now a DirGraph with the correct types

Function to add a testgraph to a dirgraph with converting-function f of the testdata ("cnfOld" resp. "cnfNew") and a Boolean, that says, if the subgraph should be expanded or not.

mkGraph2Ele0 :: Testgraph a -> DirGraph a Source

Function to add a testgraph to a dirgraph without converting-function

Conversion Functions

convertDirGraph Source

Arguments

:: (cnfB -> cnfA)

conversion function for the test-data-input of the casepart

-> (localsInB -> localsInA)

conversion function for the variables the testcases uses/changes (input-side)

-> (localsInB -> localsInA -> localsInB)

conversion function for the variables the testcases uses/changes (output-side) that is: how shall the variables look after the run of the casepart? Dependant of the old value of the variables and the value of the variables after run of the imported testcase

-> DirGraph (CasepartInternal cnfA localsInA)

the DirGraph that shall be imported

-> DirGraph (CasepartInternal cnfB localsInB)

the imported DirGraph with the correct types

Converts a DirGraph, for example our testgraphs. With that function you can import other testgraphs with another set of variables. You need a interpreting from the target data-type to the source data-type (not vice versa)

convertTestgraph Source

Arguments

:: (cnfB -> cnfA)

conversion function for the test-data-input of the casepart

-> (localsInB -> localsInA)

conversion function for the variables the testcases uses/changes (input-side)

-> (localsInB -> localsInA -> localsInB)

conversion function for the variables the testcases uses/changes (output-side) that is: how shall the variables look after the run of the casepart? Dependant of the old value of the variables and the value of the variables after run of the imported testcase

-> Testgraph (CasepartInternal cnfA localsInA)

the Testgraph that shall be imported

-> Testgraph (CasepartInternal cnfB localsInB)

the imported Testgraph with the correct types

Converts a testgraph, necessary in order to add a different testgraph ( with another type of configuration) to a dirGraph