| 147 | } |
| 148 | |
| 149 | function success (binding) { |
| 150 | return new Promise((resolve, reject) => { |
| 151 | const expected = [0, 1, 2, 3]; |
| 152 | const actual = []; |
| 153 | binding.doWork(expected.length, |
| 154 | common.mustCall((err) => { |
| 155 | if (err) { |
| 156 | reject(err); |
| 157 | } |
| 158 | }), |
| 159 | common.mustCall((_progress) => { |
| 160 | actual.push(_progress); |
| 161 | if (actual.length === expected.length) { |
| 162 | assert.deepEqual(actual, expected); |
| 163 | resolve(); |
| 164 | } |
| 165 | }, expected.length) |
| 166 | ); |
| 167 | }); |
| 168 | } |
| 169 | |
| 170 | function fail (binding) { |
| 171 | return new Promise((resolve) => { |