@@ -25,7 +25,8 @@ const { codes: {
25
25
ERR_AMBIGUOUS_ARGUMENT ,
26
26
ERR_INVALID_ARG_TYPE ,
27
27
ERR_INVALID_ARG_VALUE ,
28
- ERR_INVALID_RETURN_VALUE
28
+ ERR_INVALID_RETURN_VALUE ,
29
+ ERR_MISSING_ARGS
29
30
} } = require ( 'internal/errors' ) ;
30
31
const AssertionError = require ( 'internal/assert/assertion_error' ) ;
31
32
const { openSync, closeSync, readSync } = require ( 'fs' ) ;
@@ -351,6 +352,9 @@ assert.ok = ok;
351
352
// The equality assertion tests shallow, coercive equality with ==.
352
353
/* eslint-disable no-restricted-properties */
353
354
assert . equal = function equal ( actual , expected , message ) {
355
+ if ( arguments . length < 2 ) {
356
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
357
+ }
354
358
// eslint-disable-next-line eqeqeq
355
359
if ( actual != expected ) {
356
360
innerFail ( {
@@ -366,6 +370,9 @@ assert.equal = function equal(actual, expected, message) {
366
370
// The non-equality assertion tests for whether two objects are not
367
371
// equal with !=.
368
372
assert . notEqual = function notEqual ( actual , expected , message ) {
373
+ if ( arguments . length < 2 ) {
374
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
375
+ }
369
376
// eslint-disable-next-line eqeqeq
370
377
if ( actual == expected ) {
371
378
innerFail ( {
@@ -380,6 +387,9 @@ assert.notEqual = function notEqual(actual, expected, message) {
380
387
381
388
// The equivalence assertion tests a deep equality relation.
382
389
assert . deepEqual = function deepEqual ( actual , expected , message ) {
390
+ if ( arguments . length < 2 ) {
391
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
392
+ }
383
393
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
384
394
if ( ! isDeepEqual ( actual , expected ) ) {
385
395
innerFail ( {
@@ -394,6 +404,9 @@ assert.deepEqual = function deepEqual(actual, expected, message) {
394
404
395
405
// The non-equivalence assertion tests for any deep inequality.
396
406
assert . notDeepEqual = function notDeepEqual ( actual , expected , message ) {
407
+ if ( arguments . length < 2 ) {
408
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
409
+ }
397
410
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
398
411
if ( isDeepEqual ( actual , expected ) ) {
399
412
innerFail ( {
@@ -408,6 +421,9 @@ assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
408
421
/* eslint-enable */
409
422
410
423
assert . deepStrictEqual = function deepStrictEqual ( actual , expected , message ) {
424
+ if ( arguments . length < 2 ) {
425
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
426
+ }
411
427
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
412
428
if ( ! isDeepStrictEqual ( actual , expected ) ) {
413
429
innerFail ( {
@@ -422,6 +438,9 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
422
438
423
439
assert . notDeepStrictEqual = notDeepStrictEqual ;
424
440
function notDeepStrictEqual ( actual , expected , message ) {
441
+ if ( arguments . length < 2 ) {
442
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
443
+ }
425
444
if ( isDeepEqual === undefined ) lazyLoadComparison ( ) ;
426
445
if ( isDeepStrictEqual ( actual , expected ) ) {
427
446
innerFail ( {
@@ -435,6 +454,9 @@ function notDeepStrictEqual(actual, expected, message) {
435
454
}
436
455
437
456
assert . strictEqual = function strictEqual ( actual , expected , message ) {
457
+ if ( arguments . length < 2 ) {
458
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
459
+ }
438
460
if ( ! Object . is ( actual , expected ) ) {
439
461
innerFail ( {
440
462
actual,
@@ -447,6 +469,9 @@ assert.strictEqual = function strictEqual(actual, expected, message) {
447
469
} ;
448
470
449
471
assert . notStrictEqual = function notStrictEqual ( actual , expected , message ) {
472
+ if ( arguments . length < 2 ) {
473
+ throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
474
+ }
450
475
if ( Object . is ( actual , expected ) ) {
451
476
innerFail ( {
452
477
actual,
0 commit comments