File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ using v8::Value;
25
25
V (isExternal, IsExternal) \
26
26
V (isMap, IsMap) \
27
27
V (isMapIterator, IsMapIterator) \
28
+ V (isNativeError, IsNativeError) \
28
29
V (isPromise, IsPromise) \
29
30
V (isRegExp, IsRegExp) \
30
31
V (isSet, IsSet) \
Original file line number Diff line number Diff line change 23
23
const common = require ( '../common' ) ;
24
24
const assert = require ( 'assert' ) ;
25
25
const util = require ( 'util' ) ;
26
+ const binding = process . binding ( 'util' ) ;
26
27
const context = require ( 'vm' ) . runInNewContext ;
27
28
28
29
// isArray
@@ -153,3 +154,20 @@ util.print('test');
153
154
util . puts ( 'test' ) ;
154
155
util . debug ( 'test' ) ;
155
156
util . error ( 'test' ) ;
157
+
158
+ {
159
+ // binding.isNativeError()
160
+ assert . strictEqual ( binding . isNativeError ( new Error ( ) ) , true ) ;
161
+ assert . strictEqual ( binding . isNativeError ( new TypeError ( ) ) , true ) ;
162
+ assert . strictEqual ( binding . isNativeError ( new SyntaxError ( ) ) , true ) ;
163
+ assert . strictEqual ( binding . isNativeError ( new ( context ( 'Error' ) ) ( ) ) , true ) ;
164
+ assert . strictEqual ( binding . isNativeError ( new ( context ( 'TypeError' ) ) ( ) ) , true ) ;
165
+ assert . strictEqual ( binding . isNativeError ( new ( context ( 'SyntaxError' ) ) ( ) ) ,
166
+ true ) ;
167
+ assert . strictEqual ( binding . isNativeError ( { } ) , false ) ;
168
+ assert . strictEqual ( binding . isNativeError ( { name : 'Error' , message : '' } ) ,
169
+ false ) ;
170
+ assert . strictEqual ( binding . isNativeError ( [ ] ) , false ) ;
171
+ assert . strictEqual ( binding . isNativeError ( Object . create ( Error . prototype ) ) ,
172
+ false ) ;
173
+ }
You can’t perform that action at this time.
0 commit comments