@@ -531,10 +531,10 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
531531 ) ;
532532}
533533
534- // GH- 1941
534+ // https://github.com/nodejs/node-v0.x-archive/issues/ 1941
535535assert . strictEqual ( util . inspect ( Object . create ( Date . prototype ) ) , 'Date {}' ) ;
536536
537- // GH- 1944
537+ // https://github.com/nodejs/node-v0.x-archive/issues/ 1944
538538{
539539 const d = new Date ( ) ;
540540 d . toUTCString = null ;
@@ -549,20 +549,20 @@ assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
549549}
550550
551551// Should not throw.
552- const r = / r e g e x p / ;
553- r . toString = null ;
554- util . inspect ( r ) ;
555-
556- // Bug with user-supplied inspect function returns non-string.
557- util . inspect ( [ { inspect : ( ) => 123 } ] ) ;
552+ {
553+ const r = / r e g e x p / ;
554+ r . toString = null ;
555+ util . inspect ( r ) ;
556+ }
558557
559- // GH- 2225
558+ // See https://github.com/nodejs/node-v0.x-archive/issues/ 2225
560559{
561- const x = { inspect : util . inspect } ;
562- assert . strictEqual ( util . inspect ( x ) . includes ( 'inspect' ) , true ) ;
560+ const x = { [ util . inspect . custom ] : util . inspect } ;
561+ assert ( util . inspect ( x ) . includes (
562+ '[Symbol(util.inspect.custom)]: \n { [Function: inspect]' ) ) ;
563563}
564564
565- // util.inspect should display the escaped value of a key.
565+ // ` util.inspect` should display the escaped value of a key.
566566{
567567 const w = {
568568 '\\' : 1 ,
@@ -660,8 +660,8 @@ util.inspect({ hasOwnProperty: null });
660660}
661661
662662{
663- // "customInspect" option can enable/disable calling inspect() on objects .
664- const subject = { inspect : ( ) => 123 } ;
663+ // "customInspect" option can enable/disable calling [util. inspect.custom]() .
664+ const subject = { [ util . inspect . custom ] : ( ) => 123 } ;
665665
666666 assert . strictEqual (
667667 util . inspect ( subject , { customInspect : true } ) . includes ( '123' ) ,
@@ -680,31 +680,6 @@ util.inspect({ hasOwnProperty: null });
680680 true
681681 ) ;
682682
683- // Custom inspect() functions should be able to return other Objects.
684- subject . inspect = ( ) => ( { foo : 'bar' } ) ;
685-
686- assert . strictEqual ( util . inspect ( subject ) , '{ foo: \'bar\' }' ) ;
687-
688- subject . inspect = ( depth , opts ) => {
689- assert . strictEqual ( opts . customInspectOptions , true ) ;
690- } ;
691-
692- util . inspect ( subject , { customInspectOptions : true } ) ;
693- }
694-
695- {
696- // "customInspect" option can enable/disable calling [util.inspect.custom]().
697- const subject = { [ util . inspect . custom ] : ( ) => 123 } ;
698-
699- assert . strictEqual (
700- util . inspect ( subject , { customInspect : true } ) . includes ( '123' ) ,
701- true
702- ) ;
703- assert . strictEqual (
704- util . inspect ( subject , { customInspect : false } ) . includes ( '123' ) ,
705- false
706- ) ;
707-
708683 // A custom [util.inspect.custom]() should be able to return other Objects.
709684 subject [ util . inspect . custom ] = ( ) => ( { foo : 'bar' } ) ;
710685
@@ -717,43 +692,16 @@ util.inspect({ hasOwnProperty: null });
717692 util . inspect ( subject , { customInspectOptions : true } ) ;
718693}
719694
720- {
721- // [util.inspect.custom] takes precedence over inspect.
722- const subject = {
723- [ util . inspect . custom ] ( ) { return 123 ; } ,
724- inspect ( ) { return 456 ; }
725- } ;
726-
727- assert . strictEqual (
728- util . inspect ( subject , { customInspect : true } ) . includes ( '123' ) ,
729- true
730- ) ;
731- assert . strictEqual (
732- util . inspect ( subject , { customInspect : false } ) . includes ( '123' ) ,
733- false
734- ) ;
735- assert . strictEqual (
736- util . inspect ( subject , { customInspect : true } ) . includes ( '456' ) ,
737- false
738- ) ;
739- assert . strictEqual (
740- util . inspect ( subject , { customInspect : false } ) . includes ( '456' ) ,
741- false
742- ) ;
743- }
744-
745695{
746696 // Returning `this` from a custom inspection function works.
747- assert . strictEqual ( util . inspect ( { a : 123 , inspect ( ) { return this ; } } ) ,
748- '{ a: 123, inspect: [Function: inspect] }' ) ;
749-
750697 const subject = { a : 123 , [ util . inspect . custom ] ( ) { return this ; } } ;
751698 const UIC = 'util.inspect.custom' ;
752699 assert . strictEqual ( util . inspect ( subject ) ,
753700 `{ a: 123,\n [Symbol(${ UIC } )]: [Function: [${ UIC } ]] }` ) ;
754701}
755702
756- // util.inspect with "colors" option should produce as many lines as without it.
703+ // Using `util.inspect` with "colors" option should produce as many lines as
704+ // without it.
757705{
758706 function testLines ( input ) {
759707 const countLines = ( str ) => ( str . match ( / \n / g) || [ ] ) . length ;
@@ -1160,8 +1108,11 @@ util.inspect(process);
11601108
11611109// Setting custom inspect property to a non-function should do nothing.
11621110{
1163- const obj = { inspect : 'fhqwhgads' } ;
1164- assert . strictEqual ( util . inspect ( obj ) , "{ inspect: 'fhqwhgads' }" ) ;
1111+ const obj = { [ util . inspect . custom ] : 'fhqwhgads' } ;
1112+ assert . strictEqual (
1113+ util . inspect ( obj ) ,
1114+ "{ [Symbol(util.inspect.custom)]: 'fhqwhgads' }"
1115+ ) ;
11651116}
11661117
11671118{
0 commit comments