File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ using v8::Value;
24
24
V (isDate, IsDate) \
25
25
V (isMap, IsMap) \
26
26
V (isMapIterator, IsMapIterator) \
27
+ V (isNativeError, IsNativeError) \
27
28
V (isPromise, IsPromise) \
28
29
V (isRegExp, IsRegExp) \
29
30
V (isSet, IsSet) \
Original file line number Diff line number Diff line change 2
2
const common = require ( '../common' ) ;
3
3
const assert = require ( 'assert' ) ;
4
4
const util = require ( 'util' ) ;
5
+ const binding = process . binding ( 'util' ) ;
5
6
const context = require ( 'vm' ) . runInNewContext ;
6
7
7
8
// isArray
@@ -132,3 +133,20 @@ util.print('test');
132
133
util . puts ( 'test' ) ;
133
134
util . debug ( 'test' ) ;
134
135
util . error ( 'test' ) ;
136
+
137
+ {
138
+ // binding.isNativeError()
139
+ assert . strictEqual ( binding . isNativeError ( new Error ( ) ) , true ) ;
140
+ assert . strictEqual ( binding . isNativeError ( new TypeError ( ) ) , true ) ;
141
+ assert . strictEqual ( binding . isNativeError ( new SyntaxError ( ) ) , true ) ;
142
+ assert . strictEqual ( binding . isNativeError ( new ( context ( 'Error' ) ) ( ) ) , true ) ;
143
+ assert . strictEqual ( binding . isNativeError ( new ( context ( 'TypeError' ) ) ( ) ) , true ) ;
144
+ assert . strictEqual ( binding . isNativeError ( new ( context ( 'SyntaxError' ) ) ( ) ) ,
145
+ true ) ;
146
+ assert . strictEqual ( binding . isNativeError ( { } ) , false ) ;
147
+ assert . strictEqual ( binding . isNativeError ( { name : 'Error' , message : '' } ) ,
148
+ false ) ;
149
+ assert . strictEqual ( binding . isNativeError ( [ ] ) , false ) ;
150
+ assert . strictEqual ( binding . isNativeError ( Object . create ( Error . prototype ) ) ,
151
+ false ) ;
152
+ }
You can’t perform that action at this time.
0 commit comments