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;
2525 V (isExternal, IsExternal) \
2626 V (isMap, IsMap) \
2727 V (isMapIterator, IsMapIterator) \
28+ V (isNativeError, IsNativeError) \
2829 V (isPromise, IsPromise) \
2930 V (isRegExp, IsRegExp) \
3031 V (isSet, IsSet) \
Original file line number Diff line number Diff line change 2323const common = require ( '../common' ) ;
2424const assert = require ( 'assert' ) ;
2525const util = require ( 'util' ) ;
26+ const binding = process . binding ( 'util' ) ;
2627const context = require ( 'vm' ) . runInNewContext ;
2728
2829// isArray
@@ -153,3 +154,20 @@ util.print('test');
153154util . puts ( 'test' ) ;
154155util . debug ( 'test' ) ;
155156util . 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