Skip to content

Commit c29ffbc

Browse files
committed
prettier --write '**/*.{js,json,md}'
1 parent f82ea76 commit c29ffbc

9 files changed

+405
-377
lines changed

CHANGELOG.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@
5959

6060
### v1.19.0 (2018-08-11)
6161

62-
- [#14](https://github.com/unexpectedjs/unexpected-check/pull/14) Use proximity as a feedback loop ([Sune Simonsen](mailto:[email protected]))
62+
- [#14](https://github.com/unexpectedjs/unexpected-check/pull/14) Use proximity as a feedback loop ([Sune Simonsen](mailto:[email protected]))
6363

6464
### v1.18.0 (2018-01-13)
6565

66-
- [#13](https://github.com/unexpectedjs/unexpected-check/pull/13) Use of conditional proximity ([Andreas Lind](mailto:[email protected]), [Andreas Lind](mailto:[email protected]), [Sune Simonsen](mailto:[email protected]))
66+
- [#13](https://github.com/unexpectedjs/unexpected-check/pull/13) Use of conditional proximity ([Andreas Lind](mailto:[email protected]), [Andreas Lind](mailto:[email protected]), [Sune Simonsen](mailto:[email protected]))
6767

6868
### v1.17.0 (2018-01-08)
6969

7070
- [#12](https://github.com/unexpectedjs/unexpected-check/pull/12) I found that is yields better to results to start using the feedback quicker ([Sune Simonsen](mailto:[email protected]))
7171

7272
### v1.16.0 (2018-01-08)
7373

74-
- [#11](https://github.com/unexpectedjs/unexpected-check/pull/11) Report when the first error was found. ([Sune Simonsen](mailto:[email protected]))
74+
- [#11](https://github.com/unexpectedjs/unexpected-check/pull/11) Report when the first error was found. ([Sune Simonsen](mailto:[email protected]))
7575

7676
### v1.15.0 (2018-01-06)
7777

@@ -93,4 +93,3 @@
9393
### v1.8.0 (2016-07-17)
9494

9595
- [#3](https://github.com/unexpectedjs/unexpected-check/pull/3) Support specifying the default max number of iterations ([Andreas Lind](mailto:[email protected]))
96-

documentation/assertions/any/when-fuzzed-by.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ generator that "fuzzes", or somehow creates test cases, based on the subject.
66
```js
77
const { integer } = require('chance-generators');
88

9-
function makePrefixGenerator (str) {
10-
return integer({min: 1, max: str.length - 1}).map(prefixLength => (
9+
function makePrefixGenerator(str) {
10+
return integer({ min: 1, max: str.length - 1 }).map((prefixLength) =>
1111
str.substr(0, prefixLength)
12-
))
12+
);
1313
}
1414

1515
expect('abc', 'when fuzzed by', makePrefixGenerator, 'to match', /^a/);
@@ -21,9 +21,9 @@ prefix length to 0, we will see it generate the empty string fail:
2121

2222
```js
2323
function makePrefixGenerator(str) {
24-
return integer({ min: 0, max: str.length - 1 }).map(prefixLength => (
25-
str.substr(0, prefixLength)
26-
))
24+
return integer({ min: 0, max: str.length - 1 }).map((prefixLength) =>
25+
str.substr(0, prefixLength)
26+
);
2727
}
2828

2929
expect('abc', 'when fuzzed by', makePrefixGenerator, 'to match', /^a/);

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

+77-57
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ const escape = require('lodash.escape');
1111
const unescape = require('lodash.unescape');
1212
const { string } = require('chance-generators');
1313

14-
expect(text => {
15-
expect(unescape(escape(text)), 'to equal', text);
16-
}, 'to be valid for all', string({ max: 200 }));
14+
expect(
15+
(text) => {
16+
expect(unescape(escape(text)), 'to equal', text);
17+
},
18+
'to be valid for all',
19+
string({ max: 200 })
20+
);
1721
```
1822

1923
This will run 300 tests with random strings of length 0-200 and succeed.
@@ -22,16 +26,20 @@ You can specify the max number of iterations that the test should run and the
2226
number of errors it should collect before stopping.
2327

2428
The algorithm searches for the smallest error output, so the more errors you
25-
allow it to collect the better the output will be.
29+
allow it to collect the better the output will be.
2630

2731
```js
28-
expect(text => {
29-
expect(unescape(escape(text)), 'to equal', text);
30-
}, 'to be valid for all', {
31-
generators: [string({ max: 200 })],
32-
maxIterations: 1000,
33-
maxErrors: 30
34-
});
32+
expect(
33+
(text) => {
34+
expect(unescape(escape(text)), 'to equal', text);
35+
},
36+
'to be valid for all',
37+
{
38+
generators: [string({ max: 200 })],
39+
maxIterations: 1000,
40+
maxErrors: 30,
41+
}
42+
);
3543
```
3644

3745
I found to following code for
@@ -42,23 +50,27 @@ if that code also fulfill our round trip test:
4250
```js
4351
function rleEncode(input) {
4452
var encoding = [];
45-
input.match(/(.)\1*/g).forEach(substr => {
53+
input.match(/(.)\1*/g).forEach((substr) => {
4654
encoding.push([substr.length, substr[0]]);
4755
});
4856
return encoding;
4957
}
5058

5159
function rleDecode(encoded) {
52-
var output = "";
53-
encoded.forEach(pair => {
54-
output += new Array(1+pair[0]).join(pair[1]);
60+
var output = '';
61+
encoded.forEach((pair) => {
62+
output += new Array(1 + pair[0]).join(pair[1]);
5563
});
5664
return output;
5765
}
5866

59-
expect(text => {
60-
expect(rleDecode(rleEncode(text)), 'to equal', text);
61-
}, 'to be valid for all', string({ max: 200 }));
67+
expect(
68+
(text) => {
69+
expect(rleDecode(rleEncode(text)), 'to equal', text);
70+
},
71+
'to be valid for all',
72+
string({ max: 200 })
73+
);
6274
```
6375

6476
<!-- unexpected-markdown cleanStackTrace: true -->
@@ -91,12 +103,17 @@ Here is a test that uses more than one generator:
91103
```js
92104
const { word } = require('chance-generators');
93105

94-
expect((a, b) => {
95-
return (a + b).length === a.length + b.length;
96-
}, 'to be valid for all', word, word);
106+
expect(
107+
(a, b) => {
108+
return (a + b).length === a.length + b.length;
109+
},
110+
'to be valid for all',
111+
word,
112+
word
113+
);
97114
```
98115

99-
Another example could be to generate actions.
116+
Another example could be to generate actions.
100117

101118
Let's create a simple queue:
102119

@@ -125,30 +142,31 @@ Now let's test that items enqueued always comes out in the right order:
125142
```js
126143
const { array, pickone } = require('chance-generators');
127144

128-
var action = pickone([
129-
{ name: 'enqueue', value: string },
130-
{ name: 'dequeue' }
131-
]);
145+
var action = pickone([{ name: 'enqueue', value: string }, { name: 'dequeue' }]);
132146

133147
var actions = array(action, 200);
134148

135-
expect(function (actions) {
136-
var queue = new Queue();
137-
var enqueued = [];
138-
var dequeued = [];
139-
actions.forEach(function (action) {
140-
if (action.name === 'enqueue') {
141-
enqueued.push(action.value);
142-
queue.enqueue(action.value);
143-
} else if (!queue.isEmpty()) {
144-
dequeued.push(queue.dequeue());
145-
}
146-
});
147-
148-
queue.drainTo(dequeued);
149-
150-
expect(dequeued, 'to equal', enqueued);
151-
}, 'to be valid for all', actions);
149+
expect(
150+
function (actions) {
151+
var queue = new Queue();
152+
var enqueued = [];
153+
var dequeued = [];
154+
actions.forEach(function (action) {
155+
if (action.name === 'enqueue') {
156+
enqueued.push(action.value);
157+
queue.enqueue(action.value);
158+
} else if (!queue.isEmpty()) {
159+
dequeued.push(queue.dequeue());
160+
}
161+
});
162+
163+
queue.drainTo(dequeued);
164+
165+
expect(dequeued, 'to equal', enqueued);
166+
},
167+
'to be valid for all',
168+
actions
169+
);
152170
```
153171

154172
Support for asynchronous testing by returning a promise from the subject
@@ -157,18 +175,20 @@ function:
157175
```js#async:true
158176
expect.use(require('unexpected-stream'));
159177
160-
return expect(function (text) {
161-
return expect(
162-
text,
163-
'when piped through',
164-
[
165-
require('zlib').Gzip(),
166-
require('zlib').Gunzip()
167-
],
168-
'to yield output satisfying',
169-
'when decoded as', 'utf-8',
170-
'to equal',
171-
text
172-
);
173-
}, 'to be valid for all', string);
178+
return expect(
179+
function (text) {
180+
return expect(
181+
text,
182+
'when piped through',
183+
[require('zlib').Gzip(), require('zlib').Gunzip()],
184+
'to yield output satisfying',
185+
'when decoded as',
186+
'utf-8',
187+
'to equal',
188+
text
189+
);
190+
},
191+
'to be valid for all',
192+
string
193+
);
174194
```

0 commit comments

Comments
 (0)