Files
mercury/extras/quickcheck/tutes/T10.html
David Overton 07038626c1 The following change was made by Peter Moulder <pmoulder@csse.monash.edu.au>.
Estimated hours taken: 2

The following change was made by Peter Moulder <pmoulder@csse.monash.edu.au>.

extras/quickcheck/tutes/*.html:

	Many HTML fixes.  (Previously there were enough problems that
	it made more sense to read them as plain text files than with
	a web browser.)

	The files now pass through weblint (cleanly) and tidy (only
	`table lacks "summary" attribute' warnings remain).

	A small number of textual changes, and also a couple of
	<!-- XXX ... --> comments where I suspect the text should be
	changed.
2002-02-24 23:28:49 +00:00

97 lines
2.3 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>QuickCheck</title>
</head>
<body>
<a href="index.html">Back to main</a>
<h1>QuickCheck Tutorial 10</h1>
<h2>Summary - Generators</h2>
<p>
QuickCheck is able to generate random values for each input
argument at run time, provided that there is a default/custom
generator for that type. The master seed for randomness is the
current time.
<p>QuickCheck generates values via the following steps:
<table>
<tr>
<td>1</td>
<td>The master generator is called with 7 arguments:
<table>
<tr>
<td>Arg1</td> <td><code>type_desc</code> of the required term</td>
</tr>
<tr>
<td>Arg2</td> <td>SF for the current term</td>
</tr>
<tr>
<td>Arg3</td> <td>a list of all GF</td>
</tr>
<tr>
<td>Arg4</td> <td>a list of all custom generators</td>
</tr>
<tr>
<td>Arg5</td> <td>ouputs a univ of the generated term </td>
</tr>
<tr>
<td>Arg6</td> <td>random number supply input</td>
</tr>
<tr>
<td>Arg7</td> <td>random number supply output</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>2a</td>
<td>QuickCheck searches through the list of custom generators,
if there is a custum generator for the current term, then
call the custom generator with Arg1, 2, 3, 4, 6, 7.
The master generator will return what ever is returned by the
custom generator.</td>
</tr>
<tr>
<td>2b</td>
<td>If QuickCheck fails to locate a custom generator, then it will
classify the current term as of type int, char, float, string,
discriminated union, and other.</td>
</tr>
<tr>
<td>3b1</td>
<td>If it's type int, call rand_int/2 with Arg6 and Arg7</td>
</tr>
<tr>
<td>3b2</td>
<td>If it's type char, call rand_char/2 with Arg6 and Arg7</td>
</tr>
<tr>
<td>3b3</td>
<td>If it's type float, call rand_float/2 with Arg6 and Arg7</td>
</tr>
<tr>
<td>3b4</td>
<td>If it's type string, call rand_string/2 with Arg6 and Arg8</td>
</tr>
<tr>
<td>3b5</td>
<td>If it's type discriminated union, call rand_union/6 with
Arg1, Arg2, Arg3, Arg4, Arg6, Arg7.</td>
</tr>
<tr>
<td>3b6</td>
<td>If it's classified as other, then call rand_function with Arg1,
Arg6 and Arg7. Quickcheck will generates the appropriate value if
Arg1 is of a function with arity 0 to 10. Otherwise an error will
be thrown: "no default generator for this type".</td>
</tr>
</table>
</body>
</html>