Skip to content

Commit 24cbbf3

Browse files
committed
Update documentation with test.check name change
1 parent 5706b98 commit 24cbbf3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

doc/intro.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Introduction to simple-check
1+
# Introduction to test.check
22

3-
simple-check is a tool for writing property-based tests. This differs from
3+
test.check is a tool for writing property-based tests. This differs from
44
traditional unit-testing, where you write individual test-cases. With
5-
simple-check you write universal quantifications, properties that should hold
5+
test.check you write universal quantifications, properties that should hold
66
true for all input. For example, for all vectors, reversing the vector should
77
preserve the count. Reversing it twice should equal the input. In this guide,
88
we'll cover the thought process for coming up with properties, as well as the
@@ -16,9 +16,9 @@ the output should be in ascending order. We also might want to make sure that
1616
the count of the input is preserved. Our test might look like:
1717

1818
```clojure
19-
(require '[simple-check.core :as sc])
20-
(require '[simple-check.generators :as gen])
21-
(require '[simple-check.properties :as prop])
19+
(require '[test.check.core :as sc])
20+
(require '[test.check.generators :as gen])
21+
(require '[test.check.properties :as prop])
2222

2323
(defn ascending?
2424
"clojure.core/sorted? doesn't do what we might expect, so we write our
@@ -39,9 +39,9 @@ the count of the input is preserved. Our test might look like:
3939
```
4040

4141
What if we were to forget to actually sort our vector? The test will fail, and
42-
then simple-check will try and find 'smaller' inputs that still cause the test
42+
then test.check will try and find 'smaller' inputs that still cause the test
4343
to fail. For example, the function might originally fail with input:
44-
`[5 4 2 2 2]`, but simple-check will shrink this down to `[0 -1]` (or `[1 0]`).
44+
`[5 4 2 2 2]`, but test.check will shrink this down to `[0 -1]` (or `[1 0]`).
4545

4646
```clojure
4747
(def bad-property
@@ -60,14 +60,14 @@ generators that we write ourselves.
6060
## Generators
6161

6262
In order to write our property, we'll use generators. A generator knows how to
63-
generate random values for a specific type. The `simple-check.generators`
63+
generate random values for a specific type. The `test.check.generators`
6464
namespace has many built-in generators, as well as combinators for creating
6565
your own new generators. You can write sophisticated generators just by
6666
combining the existing generators with the given combinators. As we write
6767
generators, we can see them in practice with the `sample` function:
6868

6969
```clojure
70-
(require '[simple-check.generators :as gen])
70+
(require '[test.check.generators :as gen])
7171

7272
(gen/sample gen/int)
7373
;; => (0 1 -1 0 -1 4 4 2 7 1)
@@ -89,7 +89,7 @@ or get a lazy-seq of values:
8989
```
9090

9191
You may notice that as you ask for more values, the 'size' of the generated
92-
values increases. As simple-check generates more values, it increases the
92+
values increases. As test.check generates more values, it increases the
9393
'size' of the generated values. This allows tests to fail early, for simple
9494
values, and only increase the size as the test continues to pass.
9595

@@ -259,7 +259,7 @@ And if we try and `sample` our generator:
259259

260260
```clojure
261261
(gen/sample tree)
262-
;; => NullPointerException simple-check.generators/gen-bind/fn--1244 (generators.clj:147)
262+
;; => NullPointerException test.check.generators/gen-bind/fn--1244 (generators.clj:147)
263263
```
264264

265265
It turns out, we can't create recursive values (tree refers to itself in it's
@@ -279,12 +279,12 @@ And now if we try and `sample`:
279279

280280
```clojure
281281
(gen/sample (tree)) ;; we now have to 'call' tree to get our generator
282-
;; => StackOverflowError simple-check.generators/return (generators.clj:161)
282+
;; => StackOverflowError test.check.generators/return (generators.clj:161)
283283
```
284284

285285
Progress. It turns out, we don't have a deterministic way to stop our
286286
recursion. Our tree can just be created deeper and deeper. What we'd like is
287-
some way to control the maximum depth of the tree. Fortunately, _simple-check_
287+
some way to control the maximum depth of the tree. Fortunately, _test.check_
288288
provides a function to help: `sized`. `sized` takes a function that takes an
289289
integer size, and returns a generator based on this size. We can use this size
290290
parameter to decide when to stop recurring. We'll say that when size is 0,

0 commit comments

Comments
 (0)