Skip to content

Commit ef0d0f5

Browse files
committed
Updated chance-generators to get better shrinking
1 parent 1937300 commit ef0d0f5

File tree

4 files changed

+35
-37
lines changed

4 files changed

+35
-37
lines changed

documentation/assertions/function/to-be-valid-for-all.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ expect(function (text) {
6565
```
6666

6767
```output
68-
Ran 67 iterations and found 1 errors
68+
Ran 68 iterations and found 2 errors
6969
counterexample:
7070
7171
Generated input: ''

documentation/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ But that assumption as actually not true as the build-in sort functions is based
8181
on converting items to strings and comparing them. So you will get the following error:
8282

8383
```output
84-
Ran 44 iterations and found 20 errors
84+
Ran 43 iterations and found 20 errors
8585
counterexample:
8686
87-
Generated input: [ 4, 18 ]
87+
Generated input: [ 2, 10 ]
8888
89-
expected [ 18, 4 ] to be sorted
89+
expected [ 10, 2 ] to be sorted
9090
```
9191

9292
If we wanted to fix the problem, we would need to use a comparison function:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"author": "Sune Simonsen",
1919
"license": "MIT",
2020
"devDependencies": {
21-
"chance-generators": "1.8.0",
21+
"chance-generators": "1.11.0",
2222
"eslint": "2.7.0",
2323
"eslint-config-onelint": "1.0.2",
2424
"lodash.escape": "3.1.0",

test/unexpected-check.spec.js

+30-32
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ describe('unexpected-check', function () {
4747
maxErrors: 20
4848
});
4949
}, 'to throw',
50-
'Ran 20 iterations and found 12 errors\n' +
50+
'Ran 20 iterations and found 11 errors\n' +
5151
'counterexample:\n' +
5252
'\n' +
53-
' Generated input: [ -20, -15 ]\n' +
53+
' Generated input: [ -3, -2 ]\n' +
5454
'\n' +
55-
' expected [ -15, -20 ] first item to be less than or equal to all [ -20, -15 ]\n' +
55+
' expected [ -2, -3 ] first item to be less than or equal to all [ -3, -2 ]\n' +
5656
'\n' +
5757
' [\n' +
58-
' -20, // should be greater than or equal to -15\n' +
59-
' -15\n' +
58+
' -3, // should be greater than or equal to -2\n' +
59+
' -2\n' +
6060
' ]');
6161
});
6262

@@ -66,7 +66,7 @@ describe('unexpected-check', function () {
6666
expect(arr, 'not to contain', 2);
6767
}, 'to be valid for all', arrays);
6868
}, 'to throw',
69-
'Ran 32 iterations and found 20 errors\n' +
69+
'Ran 24 iterations and found 10 errors\n' +
7070
'counterexample:\n' +
7171
'\n' +
7272
' Generated input: [ 2 ]\n' +
@@ -94,15 +94,15 @@ describe('unexpected-check', function () {
9494
expect(items, 'not to contain', i);
9595
}, 'to be valid for all', arrays, g.integer({ min: -20, max: 20 }));
9696
}, 'to throw',
97-
'Ran 143 iterations and found 20 errors\n' +
97+
'Ran 9 iterations and found 7 errors\n' +
9898
'counterexample:\n' +
9999
'\n' +
100-
' Generated input: [ -4 ], -4\n' +
100+
' Generated input: [ 0 ], 0\n' +
101101
'\n' +
102-
' expected [ -4 ] not to contain -4\n' +
102+
' expected [ 0 ] not to contain 0\n' +
103103
'\n' +
104104
' [\n' +
105-
' -4 // should be removed\n' +
105+
' 0 // should be removed\n' +
106106
' ]');
107107
});
108108

@@ -114,19 +114,17 @@ describe('unexpected-check', function () {
114114
});
115115
}, 'to be valid for all', arrays);
116116
}, 'to throw',
117-
'Ran 282 iterations and found 20 errors\n' +
117+
'Ran 107 iterations and found 20 errors\n' +
118118
'counterexample:\n' +
119119
'\n' +
120-
' Generated input: [ -8, -5, 18, 3 ]\n' +
120+
' Generated input: [ -3, 1 ]\n' +
121121
'\n' +
122-
' expected [ -8, -5, 18, 3 ]\n' +
122+
' expected [ -3, 1 ]\n' +
123123
' to have items satisfying function (item, i) { expect(item, \'not to be\', i); }\n' +
124124
'\n' +
125125
' [\n' +
126-
' -8,\n' +
127-
' -5,\n' +
128-
' 18,\n' +
129-
' 3 // should not be 3\n' +
126+
' -3,\n' +
127+
' 1 // should not be 1\n' +
130128
' ]');
131129
});
132130

@@ -140,21 +138,21 @@ describe('unexpected-check', function () {
140138
});
141139
}, 'to be valid for all', arrays);
142140
}, 'to throw',
143-
'Ran 20 iterations and found 20 errors\n' +
141+
'Ran 5 iterations and found 4 errors\n' +
144142
'counterexample:\n' +
145143
'\n' +
146-
' Generated input: [ \']1V3ZRFOmgiE*\' ]\n' +
144+
' Generated input: [ \'(\' ]\n' +
147145
'\n' +
148-
' expected [ \']1V3ZRFOmgiE*\' ] to have items satisfying\n' +
146+
' expected [ \'(\' ] to have items satisfying\n' +
149147
' function (item) {\n' +
150148
' expect(item, \'not to match\', /[!@#$%^&*()_+]/);\n' +
151149
' }\n' +
152150
'\n' +
153151
' [\n' +
154-
' \']1V3ZRFOmgiE*\' // should not match /[!@#$%^&*()_+]/\n' +
155-
' //\n' +
156-
' // ]1V3ZRFOmgiE*\n' +
157-
' // ^\n' +
152+
' \'(\' // should not match /[!@#$%^&*()_+]/\n' +
153+
' //\n' +
154+
' // (\n' +
155+
' // ^\n' +
158156
' ]');
159157
});
160158

@@ -166,15 +164,15 @@ describe('unexpected-check', function () {
166164
}).delay(1);
167165
}, 'to be valid for all', arrays, g.integer({ min: -20, max: 20 }))
168166
, 'to be rejected with',
169-
'Ran 143 iterations and found 20 errors\n' +
167+
'Ran 9 iterations and found 7 errors\n' +
170168
'counterexample:\n' +
171169
'\n' +
172-
' Generated input: [ -4 ], -4\n' +
170+
' Generated input: [ 0 ], 0\n' +
173171
'\n' +
174-
' expected [ -4 ] not to contain -4\n' +
172+
' expected [ 0 ] not to contain 0\n' +
175173
'\n' +
176174
' [\n' +
177-
' -4 // should be removed\n' +
175+
' 0 // should be removed\n' +
178176
' ]');
179177
});
180178

@@ -190,15 +188,15 @@ describe('unexpected-check', function () {
190188
}
191189
}, 'to be valid for all', arrays, g.integer({ min: -20, max: 20 }))
192190
, 'to be rejected with',
193-
'Ran 143 iterations and found 20 errors\n' +
191+
'Ran 9 iterations and found 7 errors\n' +
194192
'counterexample:\n' +
195193
'\n' +
196-
' Generated input: [ -4 ], -4\n' +
194+
' Generated input: [ 0 ], 0\n' +
197195
'\n' +
198-
' expected [ -4 ] not to contain -4\n' +
196+
' expected [ 0 ] not to contain 0\n' +
199197
'\n' +
200198
' [\n' +
201-
' -4 // should be removed\n' +
199+
' 0 // should be removed\n' +
202200
' ]');
203201
});
204202
});

0 commit comments

Comments
 (0)