You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -49,16 +53,16 @@ That second example will fail with an error that may look something like this if
49
53
- If a property holds for all generated values, then `qcheck.given` returns `Nil`.
50
54
- If a property does not hold for all generated values, then `qcheck.given` will panic.
51
55
-`qcheck.small_non_negative_int()` generates small integers greater than or equal to zero.
52
-
-`n + 1 == 1 + n` is the property being tested in the first test.
56
+
-`should.equal(n + 1, 1 + n)` is the property being tested in the first test.
53
57
- It should be true for all generated values.
54
58
- The return value of `qcheck.given` will be `Nil`, because the property does hold for all generated values.
55
-
-`n + 1 != 1 + n` is the property being tested in the second test.
59
+
-`should.not_equal(n + 1, 1 + n)` is the property being tested in the second test.
56
60
- It should be false for all generated values.
57
61
-`qcheck.given` will be panic, because the property does not hold for all generated values.
58
62
59
63
### In-depth example
60
64
61
-
Here is a more in-depth example. We will create a simple `Point` type write some serialization functions, and then check that the serializing round-trips.
65
+
Here is a more in-depth example. We will create a simple `Point` type, write some serialization functions, and then check that the serializing round-trips.
62
66
63
67
First here is some code to define a `Point`.
64
68
@@ -155,7 +159,7 @@ fn point_generator() {
155
159
}
156
160
```
157
161
158
-
Now that we have the point generator, we can write a property test.
162
+
Now that we have the point generator, we can write a property test. (It uses the `gleeunit/should.be_true` function again.)
-`qcheck.given` will "fail" if either the property doesn't hold (e.g., returns `False`) or if there is a panic somewhere in the property function.
176
-
- Either, the points are not equal, or, the deserialization returns an `Error` (because we `assert` that it is `Ok`).
177
-
- Either one of these cases will trigger shrinking.
178
-
179
-
Let's try and run the test.
177
+
Let's try and run the test. (Note that your output won't look exactly like this.)
180
178
181
179
```
182
180
$ gleam test
@@ -212,7 +210,7 @@ You could imagine combining a property test like the one above, with a few well
212
210
213
211
(The full code for this example can be found in `test/examples/parsing_example_test.gleam`.)
214
212
215
-
### Applicative sytle
213
+
### Applicative style
216
214
217
215
The applicative style provides a nice interface for creating generators for custom types.
218
216
@@ -244,10 +242,6 @@ fn box_generator() {
244
242
}
245
243
```
246
244
247
-
### More examples
248
-
249
-
The [test](https://github.com/mooreryan/gleam_qcheck/tree/main/test) directory of this repository has many examples of setting up tests, using the built-in generators, and creating new generators. Until more dedicated documentation is written, the tests can provide some good info, as they exercise most of the available behavior. However, be aware that the tests will often use `use <- qcheck.rescue`. This is _not_ needed in your tests--it provides a way to test the `qcheck` internals.
250
-
251
245
### Integrating with testing frameworks
252
246
253
247
You don't have to do anything special to integrate `qcheck` with a testing framework like [gleeunit](https://github.com/lpil/gleeunit). The only thing required is that your testing framework of choice be able to handle panics/exceptions.
@@ -256,13 +250,9 @@ _Note: [startest](https://github.com/maxdeviant/startest) should be fine._
256
250
257
251
You may also be interested in [qcheck_gleeunit_utils](https://github.com/mooreryan/qcheck_gleeunit_utils) for running your tests in parallel and controlling test timeouts when using gleeunit and targeting Erlang.
258
252
259
-
## Roadmap
260
-
261
-
While `qcheck` has a lot of features needed to get started with property-based testing, there are still things that could be added or improved. See the `ROADMAP.md` for more information.
262
-
263
253
## Acknowledgements
264
254
265
-
Very heavily inspired by the [qcheck](https://github.com/c-cube/qcheck) and [base_quickcheck](https://github.com/janestreet/base_quickcheck) OCaml packages, and of course, the Haskell libraries from which they take inspiration.
255
+
Very heavily inspired by the [qcheck](https://github.com/c-cube/qcheck) and [base_quickcheck](https://github.com/janestreet/base_quickcheck) OCaml packages.
266
256
267
257
## Contributing
268
258
@@ -278,6 +268,6 @@ Thank you for your interest in the project!
Licensed under the Apache License, Version 2.0 or the MIT license, at your option. This program may not be copied, modified, or distributed except according to those terms.
0 commit comments