@@ -22,14 +22,16 @@ An alias of [`assert.ok()`][] .
2222``` js
2323const assert = require (' assert' );
2424
25- assert (true ); // OK
26- assert (1 ); // OK
25+ assert (true );
26+ // OK
27+ assert (1 );
28+ // OK
2729assert (false );
28- // throws "AssertionError: false == true"
30+ // throws "AssertionError: false == true"
2931assert (0 );
30- // throws "AssertionError: 0 == true"
32+ // throws "AssertionError: 0 == true"
3133assert (false , ' it\' s false' );
32- // throws "AssertionError: it's false"
34+ // throws "AssertionError: it's false"
3335```
3436
3537## assert.deepEqual(actual, expected[ , message] )
@@ -75,18 +77,18 @@ const obj3 = {
7577const obj4 = Object .create (obj1);
7678
7779assert .deepEqual (obj1, obj1);
78- // OK, object is equal to itself
80+ // OK, object is equal to itself
7981
8082assert .deepEqual (obj1, obj2);
81- // AssertionError: { a: { b: 1 } } deepEqual { a: { b: 2 } }
82- // values of b are different
83+ // AssertionError: { a: { b: 1 } } deepEqual { a: { b: 2 } }
84+ // values of b are different
8385
8486assert .deepEqual (obj1, obj3);
85- // OK, objects are equal
87+ // OK, objects are equal
8688
8789assert .deepEqual (obj1, obj4);
88- // AssertionError: { a: { b: 1 } } deepEqual {}
89- // Prototypes are ignored
90+ // AssertionError: { a: { b: 1 } } deepEqual {}
91+ // Prototypes are ignored
9092```
9193
9294If the values are not equal, an ` AssertionError ` is thrown with a ` message `
@@ -106,11 +108,11 @@ Second, object comparisons include a strict equality check of their prototypes.
106108const assert = require (' assert' );
107109
108110assert .deepEqual ({a: 1 }, {a: ' 1' });
109- // OK, because 1 == '1'
111+ // OK, because 1 == '1'
110112
111113assert .deepStrictEqual ({a: 1 }, {a: ' 1' });
112- // AssertionError: { a: 1 } deepStrictEqual { a: '1' }
113- // because 1 !== '1' using strict equality
114+ // AssertionError: { a: 1 } deepStrictEqual { a: '1' }
115+ // because 1 !== '1' using strict equality
114116```
115117
116118If the values are not equal, an ` AssertionError ` is thrown with a ` message `
@@ -184,14 +186,14 @@ using the equal comparison operator ( `==` ).
184186const assert = require (' assert' );
185187
186188assert .equal (1 , 1 );
187- // OK, 1 == 1
189+ // OK, 1 == 1
188190assert .equal (1 , ' 1' );
189- // OK, 1 == '1'
191+ // OK, 1 == '1'
190192
191193assert .equal (1 , 2 );
192- // AssertionError: 1 == 2
194+ // AssertionError: 1 == 2
193195assert .equal ({a: {b: 1 }}, {a: {b: 1 }});
194- // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
196+ // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
195197```
196198
197199If the values are not equal, an ` AssertionError ` is thrown with a ` message `
@@ -211,10 +213,10 @@ Otherwise, the error message is the value of `message`.
211213const assert = require (' assert' );
212214
213215assert .fail (1 , 2 , undefined , ' >' );
214- // AssertionError: 1 > 2
216+ // AssertionError: 1 > 2
215217
216218assert .fail (1 , 2 , ' whoops' , ' >' );
217- // AssertionError: whoops
219+ // AssertionError: whoops
218220```
219221
220222## assert.ifError(value)
@@ -228,10 +230,14 @@ argument in callbacks.
228230``` js
229231const assert = require (' assert' );
230232
231- assert .ifError (0 ); // OK
232- assert .ifError (1 ); // Throws 1
233- assert .ifError (' error' ); // Throws 'error'
234- assert .ifError (new Error ()); // Throws Error
233+ assert .ifError (0 );
234+ // OK
235+ assert .ifError (1 );
236+ // Throws 1
237+ assert .ifError (' error' );
238+ // Throws 'error'
239+ assert .ifError (new Error ());
240+ // Throws Error
235241```
236242
237243## assert.notDeepEqual(actual, expected[ , message] )
@@ -262,16 +268,16 @@ const obj3 = {
262268const obj4 = Object .create (obj1);
263269
264270assert .notDeepEqual (obj1, obj1);
265- // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
271+ // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
266272
267273assert .notDeepEqual (obj1, obj2);
268- // OK, obj1 and obj2 are not deeply equal
274+ // OK, obj1 and obj2 are not deeply equal
269275
270276assert .notDeepEqual (obj1, obj3);
271- // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
277+ // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
272278
273279assert .notDeepEqual (obj1, obj4);
274- // OK, obj1 and obj4 are not deeply equal
280+ // OK, obj1 and obj2 are not deeply equal
275281```
276282
277283If the values are deeply equal, an ` AssertionError ` is thrown with a ` message `
@@ -289,10 +295,10 @@ Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][].
289295const assert = require (' assert' );
290296
291297assert .notDeepEqual ({a: 1 }, {a: ' 1' });
292- // AssertionError: { a: 1 } notDeepEqual { a: '1' }
298+ // AssertionError: { a: 1 } notDeepEqual { a: '1' }
293299
294300assert .notDeepStrictEqual ({a: 1 }, {a: ' 1' });
295- // OK
301+ // OK
296302```
297303
298304If the values are deeply and strictly equal, an ` AssertionError ` is thrown
@@ -311,13 +317,13 @@ Tests shallow, coercive inequality with the not equal comparison operator
311317const assert = require (' assert' );
312318
313319assert .notEqual (1 , 2 );
314- // OK
320+ // OK
315321
316322assert .notEqual (1 , 1 );
317- // AssertionError: 1 != 1
323+ // AssertionError: 1 != 1
318324
319325assert .notEqual (1 , ' 1' );
320- // AssertionError: 1 != '1'
326+ // AssertionError: 1 != '1'
321327```
322328
323329If the values are equal, an ` AssertionError ` is thrown with a ` message `
@@ -336,13 +342,13 @@ Tests strict inequality as determined by the strict not equal operator
336342const assert = require (' assert' );
337343
338344assert .notStrictEqual (1 , 2 );
339- // OK
345+ // OK
340346
341347assert .notStrictEqual (1 , 1 );
342- // AssertionError: 1 != 1
348+ // AssertionError: 1 != 1
343349
344350assert .notStrictEqual (1 , ' 1' );
345- // OK
351+ // OK
346352```
347353
348354If the values are strictly equal, an ` AssertionError ` is thrown with a
@@ -364,14 +370,16 @@ parameter is `undefined`, a default error message is assigned.
364370``` js
365371const assert = require (' assert' );
366372
367- assert .ok (true ); // OK
368- assert .ok (1 ); // OK
373+ assert .ok (true );
374+ // OK
375+ assert .ok (1 );
376+ // OK
369377assert .ok (false );
370- // throws "AssertionError: false == true"
378+ // throws "AssertionError: false == true"
371379assert .ok (0 );
372- // throws "AssertionError: 0 == true"
380+ // throws "AssertionError: 0 == true"
373381assert .ok (false , ' it\' s false' );
374- // throws "AssertionError: it's false"
382+ // throws "AssertionError: it's false"
375383```
376384
377385## assert.strictEqual(actual, expected[ , message] )
@@ -385,13 +393,13 @@ Tests strict equality as determined by the strict equality operator ( `===` ).
385393const assert = require (' assert' );
386394
387395assert .strictEqual (1 , 2 );
388- // AssertionError: 1 === 2
396+ // AssertionError: 1 === 2
389397
390398assert .strictEqual (1 , 1 );
391- // OK
399+ // OK
392400
393401assert .strictEqual (1 , ' 1' );
394- // AssertionError: 1 === '1'
402+ // AssertionError: 1 === '1'
395403```
396404
397405If the values are not strictly equal, an ` AssertionError ` is thrown with a
0 commit comments