[Haskell-cafe] getting the name of a function for test diagnostic
purposes
Daniel Fischer
daniel.is.fischer at web.de
Thu Mar 3 09:28:20 EST 2005
Am Donnerstag, 3. März 2005 14:28 schrieb Terrence Brannon:
> {-
> I have written a program (below) to run a test suite for a list of
> functions:
>
> [isTotalJunc, isPartialJunc]
>
> where each function receives a datum of type ApplyArg whose value slot is
> one element at a time of the list of types below:
>
> [JNone, JOne, JAny, JAll]
>
> I therefore must run 8 tests (the cross product of functions and types).
>
> Right now, here is the output:
>
> *Main> test_total_partial
> ["fun: (->)input: JNoneoutput: True","fun: (->)input: JOneoutput:
> False","fun: (->)input: JAnyoutput: False","fun: (->)input: JAlloutput:
> True","fun: (->)input: JNoneoutput: False","fun: (->)input: JOneoutput:
> True","fun: (->)input: JAnyoutput: True","fun: (->)input: JAlloutput:
> False"]
>
> -- One problem is that functions do not print as their name. The
> call to (show f) in showres simply yields (->)
>
> -- Another problem is that I cannot manage to separate each string
> with a carriage return.
>
> Any help with these problems is appreciated.
>
> -}
>
> test_total_partial = let funs = [isTotalJunc, isPartialJunc]
> types = [JNone, JOne, JAny, JAll]
> mkdat typ = ApplyArg "somename" (VJunc $ Junc typ emptySet emptySet)
> False showres f t r = "fun: " ++ (show f) ++ "input: " ++ (show t) ++
> "output: " ++ (show r) runtest f t = do {
> retval <- f (mkdat t);
> return $ (showres f t retval)
> }
> in
> [ (showres f t (f (mkdat t))) | f <- funs, t <- types ]
Well, getting the name of a function, I don't know how to.
But as for separating the Strings, what about 'unlines'?
Daniel
More information about the Haskell-Cafe
mailing list