Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use the seed cache when creating iterators in 'to be valid for all' #73

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/assertions/any/when-fuzzed-by.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ expect('abc', 'when fuzzed by', makePrefixGenerator, 'to match', /^a/);
```

```output
Found an error after 1 iteration
Found an error after 4 iterations
counterexample:

Generated input: ''
Expand Down
2 changes: 1 addition & 1 deletion documentation/assertions/function/to-be-valid-for-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ expect(text => {
```

```output
Found an error after 78 iterations
Found an error after 220 iterations
counterexample:

Generated input: ''
Expand Down
8 changes: 4 additions & 4 deletions documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ But that assumption is actually not true as the build-in sort functions is based
on converting items to strings and comparing them. So you will get the following error:

```output
Found an error after 1 iteration, 122 additional errors found.
Found an error after 1 iteration, 107 additional errors found.
counterexample:

Generated input: [ -2, -1 ]
Expand Down Expand Up @@ -216,13 +216,13 @@ expect((arr) => {
```

```output
Found an error after 2 iterations, 9 additional errors found.
Found an error after 1 iteration, 9 additional errors found.
counterexample:

Generated input: [ 0, 0, -1, 0, -1, 0, 7, -7 ]
Generated input: [ 0, 0, -2, -1 ]
with: array({ itemGenerator: integer({ min: -20, max: 20 }), min: 1, max: 20 })

expected [ -1, -1, -7, 0, 0, 0, 0, 7 ] to be sorted
expected [ -1, -2, 0, 0 ] to be sorted
```

As you can see the input shrinking is worse with less iterations, but it will be
Expand Down
8 changes: 4 additions & 4 deletions lib/unexpected-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@
);
}

return generator.values();
return generator.values({ skipSeedCache: true });
});

function resetIterators() {
iterators = generators.map(function(generator) {
return generator.values();
return generator.values({ skipSeedCache: true });
});
}

Expand Down Expand Up @@ -401,8 +401,8 @@
};
}

FuzzedGenerator.prototype.values = function() {
return this.options.mutator.values();
FuzzedGenerator.prototype.values = function(options) {
return this.options.mutator.values(options);
};

expect.addAssertion(
Expand Down
24 changes: 12 additions & 12 deletions test/unexpected-check.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ describe('unexpected-check', function() {
);
},
'to throw',
'Found an error after 1 iteration, 25 additional errors found.\n' +
'Found an error after 1 iteration, 20 additional errors found.\n' +
'counterexample:\n' +
'\n' +
' Generated input: [ -1, -2 ]\n' +
' Generated input: [ -2, -1 ]\n' +
' with: array({ itemGenerator: integer({ min: -20, max: 20 }), min: 1, max: 20 })\n' +
'\n' +
' expected [ -1, -2 ] to be sorted'
Expand All @@ -74,7 +74,7 @@ describe('unexpected-check', function() {
);
},
'to throw',
'Found an error after 3 iterations, 200 additional errors found.\n' +
'Found an error after 8 iterations, 200 additional errors found.\n' +
'counterexample:\n' +
'\n' +
' Generated input: [ 2 ]\n' +
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('unexpected-check', function() {
);
},
'to throw',
'Found an error after 1 iteration, 6 additional errors found.\n' +
'Found an error after 3 iterations, 10 additional errors found.\n' +
'counterexample:\n' +
'\n' +
' Generated input: [ 0 ], 0\n' +
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('unexpected-check', function() {
);
},
'to throw',
'Found an error after 3 iterations, 12 additional errors found.\n' +
'Found an error after 4 iterations, 16 additional errors found.\n' +
'counterexample:\n' +
'\n' +
' Generated input: [ 0 ]\n' +
Expand Down Expand Up @@ -182,15 +182,15 @@ describe('unexpected-check', function() {
'Found an error after 1 iteration, 200 additional errors found.\n' +
'counterexample:\n' +
'\n' +
" Generated input: [ '#' ]\n" +
" Generated input: [ ')' ]\n" +
' with: array({ itemGenerator: string, min: 1, max: 20 })\n' +
'\n' +
" expected [ '#' ] to have items satisfying not to match /[!@#$%^&*()_+]/\n" +
" expected [ ')' ] to have items satisfying not to match /[!@#$%^&*()_+]/\n" +
'\n' +
' [\n' +
" '#' // should not match /[!@#$%^&*()_+]/\n" +
" ')' // should not match /[!@#$%^&*()_+]/\n" +
' //\n' +
' // #\n' +
' // )\n' +
' // ^\n' +
' ]'
);
Expand All @@ -211,7 +211,7 @@ describe('unexpected-check', function() {
integer({ min: -20, max: 20 })
),
'to be rejected with',
'Found an error after 6 iterations, 14 additional errors found.\n' +
'Found an error after 3 iterations, 10 additional errors found.\n' +
'counterexample:\n' +
'\n' +
' Generated input: [ 0 ], 0\n' +
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('unexpected-check', function() {
);
},
'to error',
'Found an error after 2 iterations, 12 additional errors found.\n' +
'Found an error after 3 iterations, 10 additional errors found.\n' +
'counterexample:\n' +
'\n' +
' Generated input: [ 0 ], 0\n' +
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('unexpected-check', function() {
);
},
'to error with',
'Found an error after 4 iterations, 1 additional error found.\n' +
'Found an error after 1 iteration, 1 additional error found.\n' +
'counterexample:\n' +
'\n' +
" Generated input: 'a'\n" +
Expand Down