You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -182,9 +197,15 @@ function checkForPlaceholders( actual, expected ) {
182
197
returnisArrayBuffer(actual);
183
198
case'<BigInt>':
184
199
returnisBigInt(actual);
200
+
case'<BigInt64Array>':
201
+
returnisBigInt64Array(actual);
202
+
case'<BigUint64Array>':
203
+
returnisBigUint64Array(actual);
185
204
case'<boolean>':
186
205
case'<Boolean>':
187
206
returnisBoolean(actual);
207
+
case'<BooleanArray>':
208
+
returnisBooleanArray(actual);
188
209
case'<Buffer>':
189
210
returnisBuffer(actual);
190
211
case'<Complex64>':
@@ -203,8 +224,18 @@ function checkForPlaceholders( actual, expected ) {
203
224
returnisError(actual);
204
225
case'<EvalError>':
205
226
returnisEvalError(actual);
227
+
case'<Float32Array>':
228
+
returnisFloat32Array(actual);
229
+
case'<Float64Array>':
230
+
returnisFloat64Array(actual);
206
231
case'<Function>':
207
232
returnisFunction(actual);
233
+
case'<Int8Array>':
234
+
returnisInt8Array(actual);
235
+
case'<Int16Array>':
236
+
returnisInt16Array(actual);
237
+
case'<Int32Array>':
238
+
returnisInt32Array(actual);
208
239
case'<MultiSlice>':
209
240
returnisMultiSlice(actual);
210
241
case'<ndarray>':
@@ -237,12 +268,20 @@ function checkForPlaceholders( actual, expected ) {
237
268
returnisTypeError(actual);
238
269
case'<TypedArray>':
239
270
returnisTypedArray(actual);
271
+
case'<Uint8Array>':
272
+
returnisUint8Array(actual);
273
+
case'<Uint8ClampedArray>':
274
+
returnisUint8ClampedArray(actual);
275
+
case'<Uint16Array>':
276
+
returnisUint16Array(actual);
277
+
case'<Uint32Array>':
278
+
returnisUint32Array(actual);
240
279
case'<URIError>':
241
280
returnisURIError(actual);
242
281
default:
243
282
// Unknown type, let it slide...
244
283
245
-
// FIXME: should we compare constructor names here at a minimum?
284
+
// TODO: should we compare constructor names here at a minimum?
246
285
returntrue;
247
286
}
248
287
}
@@ -269,12 +308,50 @@ function compareEntries( actual, expected ) {
269
308
}
270
309
271
310
/**
272
-
* For a typed array, if the return annotation asserts deep instance equality, check whether it corresponds to the actual value; otherwise, check whether the return annotation signals the correct type.
311
+
* Checks whether a complex number matches the expected return annotation.
273
312
*
274
313
* @private
275
314
* @param {*} actual - actual return value
276
315
* @param {string} expected - return value annotation
277
-
* @returns {(string|null)} error message in case the annotation and value do not match, `null` otherwise
316
+
* @returns {(string|null)} error message or null
317
+
*/
318
+
functioncheckComplex(actual,expected){
319
+
varentries;
320
+
varmatch;
321
+
vartype;
322
+
323
+
match=RE_INSTANCE_ANNOTATION.exec(expected);
324
+
if(match){
325
+
type=match[1];
326
+
entries=match[2];
327
+
if(actual.constructor.name!==type){
328
+
return'Expected instance type <'+actual.constructor.name+'>, but observed <'+type+'>';
329
+
}
330
+
if(entries){
331
+
if(isComplex128(actual)){
332
+
actual=[real(actual),imag(actual)];
333
+
}elseif(isComplex64(actual)){
334
+
actual=[realf(actual),imagf(actual)];
335
+
}
336
+
returncompareEntries(actual,parse(entries));
337
+
}
338
+
returnnull;
339
+
}
340
+
return'Complex numbers should be documented using instance annotation';
341
+
}
342
+
343
+
/**
344
+
* Checks whether a typed array matches the expected return annotation.
345
+
*
346
+
* ## Notes
347
+
*
348
+
* - If the return annotation asserts deep instance equality, check whether it corresponds to the actual value.
349
+
* - Otherwise, check whether the return annotation signals the correct type.
350
+
*
351
+
* @private
352
+
* @param {*} actual - actual return value
353
+
* @param {string} expected - return value annotation
354
+
* @returns {(string|null)} error message or null
278
355
*/
279
356
functioncheckTypedArrays(actual,expected){
280
357
varentries;
@@ -455,6 +532,9 @@ function compareValues( actual, expected ) {
0 commit comments