Skip to content

Commit c5f610d

Browse files
committed
docs: add built-in conjecture examples
1 parent 5a7d57e commit c5f610d

File tree

1 file changed

+95
-1
lines changed

1 file changed

+95
-1
lines changed

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,100 @@ Traceback (most recent call last):
3232
AssertionError
3333
```
3434

35+
### Built-in conjectures
36+
37+
#### General
38+
39+
Matching none.
40+
41+
```pycon
42+
>>> import conjecture
43+
>>> assert None == conjecture.none()
44+
```
45+
46+
Matching anything.
47+
48+
```pycon
49+
>>> import conjecture
50+
>>> assert None == conjecture.anything()
51+
>>> assert 123 == conjecture.anything()
52+
>>> assert "abc" == conjecture.anything()
53+
```
54+
55+
#### Object
56+
57+
Matching instances of a class.
58+
59+
```pycon
60+
>>> import conjecture
61+
>>> assert 123 == conjecture.instance_of(int)
62+
>>> assert "abc" == conjecture.instance_of((str, bytes))
63+
```
64+
65+
Matching values.
66+
67+
```pycon
68+
>>> import conjecture
69+
>>> assert 123 == conjecture.equal_to(123)
70+
>>> assert "abc" == conjecture.equal_to("abc")
71+
```
72+
73+
#### Rich ordering
74+
75+
Matching lesser values.
76+
77+
```pycon
78+
>>> import conjecture
79+
>>> assert 5 == conjecture.greater_than(1)
80+
>>> assert 5 == conjecture.greater_than_or_equal_to(1)
81+
```
82+
83+
Matching greater values.
84+
85+
```pycon
86+
>>> import conjecture
87+
>>> assert 1 == conjecture.less_than(5)
88+
>>> assert 1 == conjecture.less_than_or_equal_to(5)
89+
```
90+
91+
#### Size
92+
93+
Matching empty collections.
94+
95+
```pycon
96+
>>> import conjecture
97+
>>> assert list() == conjecture.empty()
98+
>>> assert set() == conjecture.empty()
99+
>>> assert tuple() == conjecture.empty()
100+
>>> assert dict() == conjecture.empty()
101+
```
102+
103+
Matching length of collections.
104+
105+
```pycon
106+
>>> import conjecture
107+
>>> assert [1, 2, 3, 4, 5] == conjecture.length_of(5)
108+
>>> assert [1, 2, 3] == conjecture.length_of(conjecture.less_than(5))
109+
```
110+
111+
#### String
112+
113+
Matching string prefixes.
114+
115+
```pycon
116+
>>> import conjecture
117+
>>> assert "foo bar baz" == conjecture.prefixed_with("foo")
118+
>>> assert b"foo bar baz" == conjecture.prefixed_with(b"foo")
119+
```
120+
121+
Matching string suffixes.
122+
123+
```pycon
124+
>>> import conjecture
125+
>>> assert "foo bar baz" == conjecture.suffixed_with("baz")
126+
>>> assert b"foo bar baz" == conjecture.suffixed_with(b"baz")
127+
```
128+
35129
### Combined conjectures
36130

37131
Matching all conditions.
@@ -104,4 +198,4 @@ All documentation and images are licenced under the
104198

105199
## 📝 Meta
106200

107-
This project uses [Semantic Versioning](http://semver.org/).
201+
This project uses [Semantic Versioning](http://semver.org/).

0 commit comments

Comments
 (0)