Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
curry-packages
currycheck
Commits
313dd2c1
Commit
313dd2c1
authored
Dec 14, 2018
by
Michael Hanus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manual updated
parent
4f4f7ea6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
docs/manual.tex
docs/manual.tex
+24
-8
No files found.
docs/manual.tex
View file @
313dd2c1
\section
{
\texttt
{
c
urry
c
heck
}
: A Tool for Testing Properties of Curry Programs
}
\section
{
C
urry
C
heck: A Tool for Testing Properties of Curry Programs
}
\label
{
sec-currycheck
}
CurryCheck
\index
{
CurryCheck
}
\index
{
testing programs
}
\index
{
program!testing
}
...
...
@@ -14,6 +14,22 @@ by combinators proposed for EasyCheck, which are actually
influenced by QuickCheck
\cite
{
ClaessenHughes00
}
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
}
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.
If our program is stored in the file
\code
{
Rev.curry
}
,
we can execute the tests as follows:
\begin{curry}
> curry
check Rev
> curry
-
check Rev
...
Executing all tests...
revNull (module Rev, line 7):
...
...
@@ -91,12 +107,12 @@ where \code{Prop} denotes the type of a test:
revRevIsId :: [Int] -> Prop
revRevIsId xs = rev (rev xs) -=- xs
\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
(only errors and failed tests are reported) or
\ccode
{
-v
}
for a verbose execution where all generated test cases
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
}
.
Hence, CurryCheck can be easily integrated in tool chains
for automatic testing.
...
...
@@ -217,7 +233,7 @@ permIsEventuallySorted xs = eventually $\code{\$}$ sorted (perm xs)
The previous operations can be exploited to provide
a high-level specification of sorting a list:
\begin{curry}
psort :: [Int] -> [Int
}
psort :: [Int] -> [Int
]
psort xs | sorted ys = ys
where ys = perm xs
\end{curry}
...
...
@@ -241,7 +257,7 @@ qsortIsSorting xs = qsort xs <~> psort xs
Actually, if we test this property, we obtain a failure:
%
\begin{curry}
> curry
check ExampleTests
> curry
-
check ExampleTests
...
qsortIsSorting (module ExampleTests, line 53) failed
Falsified by third test.
...
...
@@ -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:
%
\begin{curry}
> curry
check -v ExampleTests
> curry
-
check -v ExampleTests
...
0:
False
...
...
@@ -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
%
\begin{curry}
> curry
check -m 200 ExampleTests
> curry
-
check -m 200 ExampleTests
\end{curry}
%
For a given type, CurryCheck automatically enumerates all values
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment