@@ -5,6 +5,7 @@ const common = require('../common');
5
5
6
6
const assert = require ( 'assert' ) ;
7
7
const { customInspectSymbol : inspect } = require ( 'internal/util' ) ;
8
+ const util = require ( 'util' ) ;
8
9
9
10
const buf = Buffer . from ( [ 0xef , 0xbb , 0xbf , 0x74 , 0x65 ,
10
11
0x73 , 0x74 , 0xe2 , 0x82 , 0xac ] ) ;
@@ -97,6 +98,42 @@ if (common.hasIntl) {
97
98
assert . strictEqual ( res , 'test€' ) ;
98
99
}
99
100
101
+ // Test TextDecoder inspect with hidden fields
102
+ {
103
+ const dec = new TextDecoder ( 'utf-8' , { ignoreBOM : true } ) ;
104
+ if ( common . hasIntl ) {
105
+ assert . strictEqual (
106
+ util . inspect ( dec , { showHidden : true } ) ,
107
+ 'TextDecoder {\n encoding: \'utf-8\',\n fatal: false,\n ' +
108
+ 'ignoreBOM: true,\n [Symbol(flags)]: 4,\n [Symbol(handle)]: {} }'
109
+ ) ;
110
+ } else {
111
+ assert . strictEqual (
112
+ util . inspect ( dec , { showHidden : true } ) ,
113
+ 'TextDecoder {\n encoding: \'utf-8\',\n fatal: false,\n ' +
114
+ 'ignoreBOM: true,\n [Symbol(flags)]: 4,\n [Symbol(handle)]:\n ' +
115
+ 'StringDecoder {\n encoding: \'utf8\',\n ' +
116
+ '[Symbol(kNativeDecoder)]: <Buffer 00 00 00 00 00 00 01> } }'
117
+ ) ;
118
+ }
119
+ }
120
+
121
+
122
+ // Test TextDecoder inspect without hidden fields
123
+ {
124
+ const dec = new TextDecoder ( 'utf-8' , { ignoreBOM : true } ) ;
125
+ assert . strictEqual (
126
+ util . inspect ( dec , { showHidden : false } ) ,
127
+ 'TextDecoder { encoding: \'utf-8\', fatal: false, ignoreBOM: true }'
128
+ ) ;
129
+ }
130
+
131
+ // Test TextDecoder inspect with negative depth
132
+ {
133
+ const dec = new TextDecoder ( ) ;
134
+ assert . strictEqual ( util . inspect ( dec , { depth : - 1 } ) , '[Object]' ) ;
135
+ }
136
+
100
137
{
101
138
const inspectFn = TextDecoder . prototype [ inspect ] ;
102
139
const decodeFn = TextDecoder . prototype . decode ;
0 commit comments