Commit 313dd2c1 authored by Michael Hanus 's avatar Michael Hanus

Manual updated

parent 4f4f7ea6
\section{\texttt{curry check}: A Tool for Testing Properties of Curry Programs} \section{CurryCheck: A Tool for Testing Properties of Curry Programs}
\label{sec-currycheck} \label{sec-currycheck}
CurryCheck\index{CurryCheck}\index{testing programs}\index{program!testing} CurryCheck\index{CurryCheck}\index{testing programs}\index{program!testing}
...@@ -14,6 +14,22 @@ by combinators proposed for EasyCheck, which are actually ...@@ -14,6 +14,22 @@ by combinators proposed for EasyCheck, which are actually
influenced by QuickCheck \cite{ClaessenHughes00} influenced by QuickCheck \cite{ClaessenHughes00}
but extended to the demands of functional logic programming. but extended to the demands of functional logic programming.
\subsection{Installation}
The current implementation of CurryCheck is a package
managed by the Curry Package Manager CPM.
Thus, to install the newest version of CurryCheck, use the following commands:
%
\begin{curry}
> cypm update
> cypm install currycheck
\end{curry}
%
This downloads the newest package, compiles it, and places
the executable \code{curry-check} into the directory \code{\$HOME/.cpm/bin}.
Hence it is recommended to add this directory to your path
in order to execute CurryCheck as described below.
\subsection{Testing Properties} \subsection{Testing Properties}
To start with a concrete example, consider the following naive definition of To start with a concrete example, consider the following naive definition of
...@@ -68,7 +84,7 @@ Now we can run all tests by invoking the CurryCheck tool. ...@@ -68,7 +84,7 @@ Now we can run all tests by invoking the CurryCheck tool.
If our program is stored in the file \code{Rev.curry}, If our program is stored in the file \code{Rev.curry},
we can execute the tests as follows: we can execute the tests as follows:
\begin{curry} \begin{curry}
> curry check Rev > curry-check Rev
... ...
Executing all tests... Executing all tests...
revNull (module Rev, line 7): revNull (module Rev, line 7):
...@@ -91,12 +107,12 @@ where \code{Prop} denotes the type of a test: ...@@ -91,12 +107,12 @@ where \code{Prop} denotes the type of a test:
revRevIsId :: [Int] -> Prop revRevIsId :: [Int] -> Prop
revRevIsId xs = rev (rev xs) -=- xs revRevIsId xs = rev (rev xs) -=- xs
\end{curry} \end{curry}
The command \code{curry check} has some options to influence The command \code{curry-check} has some options to influence
the output, like \ccode{-q} for a quiet execution the output, like \ccode{-q} for a quiet execution
(only errors and failed tests are reported) or (only errors and failed tests are reported) or
\ccode{-v} for a verbose execution where all generated test cases \ccode{-v} for a verbose execution where all generated test cases
are shown. are shown.
Moreover, the return code of \code{curry check} is \code{0} Moreover, the return code of \code{curry-check} is \code{0}
in case of successful tests, otherwise, it is \code{1}. in case of successful tests, otherwise, it is \code{1}.
Hence, CurryCheck can be easily integrated in tool chains Hence, CurryCheck can be easily integrated in tool chains
for automatic testing. for automatic testing.
...@@ -217,7 +233,7 @@ permIsEventuallySorted xs = eventually $\code{\$}$ sorted (perm xs) ...@@ -217,7 +233,7 @@ permIsEventuallySorted xs = eventually $\code{\$}$ sorted (perm xs)
The previous operations can be exploited to provide The previous operations can be exploited to provide
a high-level specification of sorting a list: a high-level specification of sorting a list:
\begin{curry} \begin{curry}
psort :: [Int] -> [Int} psort :: [Int] -> [Int]
psort xs | sorted ys = ys psort xs | sorted ys = ys
where ys = perm xs where ys = perm xs
\end{curry} \end{curry}
...@@ -241,7 +257,7 @@ qsortIsSorting xs = qsort xs <~> psort xs ...@@ -241,7 +257,7 @@ qsortIsSorting xs = qsort xs <~> psort xs
Actually, if we test this property, we obtain a failure: Actually, if we test this property, we obtain a failure:
% %
\begin{curry} \begin{curry}
> curry check ExampleTests > curry-check ExampleTests
... ...
qsortIsSorting (module ExampleTests, line 53) failed qsortIsSorting (module ExampleTests, line 53) failed
Falsified by third test. Falsified by third test.
...@@ -284,7 +300,7 @@ neg_or b1 b2 = not (b1 || b2) -=- not b1 && not b2 ...@@ -284,7 +300,7 @@ neg_or b1 b2 = not (b1 || b2) -=- not b1 && not b2
This property is validated by checking it with all possible values: This property is validated by checking it with all possible values:
% %
\begin{curry} \begin{curry}
> curry check -v ExampleTests > curry-check -v ExampleTests
... ...
0: 0:
False False
...@@ -309,7 +325,7 @@ by the command-line flag \ccode{-m}. For instance, to test ...@@ -309,7 +325,7 @@ by the command-line flag \ccode{-m}. For instance, to test
each property with 200 tests, CurryCheck can be invoked by each property with 200 tests, CurryCheck can be invoked by
% %
\begin{curry} \begin{curry}
> curry check -m 200 ExampleTests > curry-check -m 200 ExampleTests
\end{curry} \end{curry}
% %
For a given type, CurryCheck automatically enumerates all values For a given type, CurryCheck automatically enumerates all values
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment