Skip to content

Commit aa4d063

Browse files
committed
Upgraded chance-generators to get even better shrinking
1 parent ef0d0f5 commit aa4d063

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
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 68 iterations and found 2 errors
68+
Ran 67 iterations and found 1 errors
6969
counterexample:
7070
7171
Generated input: ''

documentation/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ 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 43 iterations and found 20 errors
84+
Ran 300 iterations and found 8 errors
8585
counterexample:
8686
87-
Generated input: [ 2, 10 ]
87+
Generated input: [ 10, 2 ]
8888
8989
expected [ 10, 2 ] to be sorted
9090
```

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.11.0",
21+
"chance-generators": "1.12.0",
2222
"eslint": "2.7.0",
2323
"eslint-config-onelint": "1.0.2",
2424
"lodash.escape": "3.1.0",

test/unexpected-check.spec.js

+23-24
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ describe('unexpected-check', function () {
4343
.and('last item to be greater than or equal to all', arr);
4444
}, 'to be valid for all', {
4545
generators: [arrays],
46-
maxIterations: 20,
46+
maxIterations: 150,
4747
maxErrors: 20
4848
});
4949
}, 'to throw',
50-
'Ran 20 iterations and found 11 errors\n' +
50+
'Ran 150 iterations and found 13 errors\n' +
5151
'counterexample:\n' +
5252
'\n' +
53-
' Generated input: [ -3, -2 ]\n' +
53+
' Generated input: [ -1, -2 ]\n' +
5454
'\n' +
55-
' expected [ -2, -3 ] first item to be less than or equal to all [ -3, -2 ]\n' +
55+
' expected [ -1, -2 ] first item to be less than or equal to all [ -1, -2 ]\n' +
5656
'\n' +
5757
' [\n' +
58-
' -3, // should be greater than or equal to -2\n' +
59-
' -2\n' +
58+
' -1,\n' +
59+
' -2 // should be greater than or equal to -1\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 24 iterations and found 10 errors\n' +
69+
'Ran 62 iterations and found 20 errors\n' +
7070
'counterexample:\n' +
7171
'\n' +
7272
' Generated input: [ 2 ]\n' +
@@ -94,7 +94,7 @@ 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 9 iterations and found 7 errors\n' +
97+
'Ran 10 iterations and found 8 errors\n' +
9898
'counterexample:\n' +
9999
'\n' +
100100
' Generated input: [ 0 ], 0\n' +
@@ -114,17 +114,16 @@ describe('unexpected-check', function () {
114114
});
115115
}, 'to be valid for all', arrays);
116116
}, 'to throw',
117-
'Ran 107 iterations and found 20 errors\n' +
117+
'Ran 18 iterations and found 5 errors\n' +
118118
'counterexample:\n' +
119119
'\n' +
120-
' Generated input: [ -3, 1 ]\n' +
120+
' Generated input: [ 0 ]\n' +
121121
'\n' +
122-
' expected [ -3, 1 ]\n' +
122+
' expected [ 0 ]\n' +
123123
' to have items satisfying function (item, i) { expect(item, \'not to be\', i); }\n' +
124124
'\n' +
125125
' [\n' +
126-
' -3,\n' +
127-
' 1 // should not be 1\n' +
126+
' 0 // should not be 0\n' +
128127
' ]');
129128
});
130129

@@ -138,20 +137,20 @@ describe('unexpected-check', function () {
138137
});
139138
}, 'to be valid for all', arrays);
140139
}, 'to throw',
141-
'Ran 5 iterations and found 4 errors\n' +
140+
'Ran 152 iterations and found 20 errors\n' +
142141
'counterexample:\n' +
143142
'\n' +
144-
' Generated input: [ \'(\' ]\n' +
143+
' Generated input: [ \'#\' ]\n' +
145144
'\n' +
146-
' expected [ \'(\' ] to have items satisfying\n' +
145+
' expected [ \'#\' ] to have items satisfying\n' +
147146
' function (item) {\n' +
148147
' expect(item, \'not to match\', /[!@#$%^&*()_+]/);\n' +
149148
' }\n' +
150149
'\n' +
151150
' [\n' +
152-
' \'(\' // should not match /[!@#$%^&*()_+]/\n' +
151+
' \'#\' // should not match /[!@#$%^&*()_+]/\n' +
153152
' //\n' +
154-
' // (\n' +
153+
' // #\n' +
155154
' // ^\n' +
156155
' ]');
157156
});
@@ -164,7 +163,7 @@ describe('unexpected-check', function () {
164163
}).delay(1);
165164
}, 'to be valid for all', arrays, g.integer({ min: -20, max: 20 }))
166165
, 'to be rejected with',
167-
'Ran 9 iterations and found 7 errors\n' +
166+
'Ran 10 iterations and found 8 errors\n' +
168167
'counterexample:\n' +
169168
'\n' +
170169
' Generated input: [ 0 ], 0\n' +
@@ -177,18 +176,18 @@ describe('unexpected-check', function () {
177176
});
178177

179178
it('supports a mix between synchronous and asynchronous bodies', function () {
180-
return expect(
181-
expect(function (items, i) {
179+
return expect(function () {
180+
return expect(function (items, i) {
182181
if (i % 2 === 0) {
183182
expect(items, 'not to contain', i);
184183
} else {
185184
return expect.promise(function () {
186185
expect(items, 'not to contain', i);
187186
}).delay(1);
188187
}
189-
}, 'to be valid for all', arrays, g.integer({ min: -20, max: 20 }))
190-
, 'to be rejected with',
191-
'Ran 9 iterations and found 7 errors\n' +
188+
}, 'to be valid for all', arrays, g.integer({ min: -20, max: 20 }));
189+
}, 'to error',
190+
'Ran 10 iterations and found 8 errors\n' +
192191
'counterexample:\n' +
193192
'\n' +
194193
' Generated input: [ 0 ], 0\n' +

0 commit comments

Comments
 (0)