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 @@ -24,6 +24,7 @@ using v8::Value;
2424  V (isDate, IsDate)                                                           \
2525  V (isMap, IsMap)                                                             \
2626  V (isMapIterator, IsMapIterator)                                             \
27+   V (isNativeError, IsNativeError)                                             \
2728  V (isPromise, IsPromise)                                                     \
2829  V (isRegExp, IsRegExp)                                                       \
2930  V (isSet, IsSet)                                                             \
Original file line number Diff line number Diff line change 22const  common  =  require ( '../common' ) ; 
33const  assert  =  require ( 'assert' ) ; 
44const  util  =  require ( 'util' ) ; 
5+ const  binding  =  process . binding ( 'util' ) ; 
56const  context  =  require ( 'vm' ) . runInNewContext ; 
67
78// isArray 
@@ -132,3 +133,20 @@ util.print('test');
132133util . puts ( 'test' ) ; 
133134util . debug ( 'test' ) ; 
134135util . 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