11'use strict' ; 
22
3- require ( '../common' ) ; 
3+ const   common   =   require ( '../common' ) ; 
44const  assert  =  require ( 'assert' ) ; 
55
66const  b  =  Buffer . allocUnsafe ( 1024 ) ; 
77const  c  =  Buffer . allocUnsafe ( 512 ) ; 
8+ 
9+ const  errorProperty  =  { 
10+   code : 'ERR_OUT_OF_RANGE' , 
11+   type : RangeError , 
12+   message : 'Index out of range' 
13+ } ; 
14+ 
815let  cntr  =  0 ; 
916
1017{ 
@@ -96,9 +103,9 @@ bb.fill('hello crazy world');
96103b . copy ( c ,  0 ,  100 ,  10 ) ; 
97104
98105// copy throws at negative sourceStart 
99- assert . throws ( function ( )   { 
100-   Buffer . allocUnsafe ( 5 ) . copy ( Buffer . allocUnsafe ( 5 ) ,  0 ,  - 1 ) ; 
101- } ,   RangeError ) ; 
106+ common . expectsError ( 
107+   ( )   =>   Buffer . allocUnsafe ( 5 ) . copy ( Buffer . allocUnsafe ( 5 ) ,  0 ,  - 1 ) , 
108+    errorProperty ) ; 
102109
103110{ 
104111  // check sourceEnd resets to targetEnd if former is greater than the latter 
@@ -111,7 +118,8 @@ assert.throws(function() {
111118} 
112119
113120// throw with negative sourceEnd 
114- assert . throws ( ( )  =>  b . copy ( c ,  0 ,  0 ,  - 1 ) ,  RangeError ) ; 
121+ common . expectsError ( 
122+   ( )  =>  b . copy ( c ,  0 ,  - 1 ) ,  errorProperty ) ; 
115123
116124// when sourceStart is greater than sourceEnd, zero copied 
117125assert . strictEqual ( b . copy ( c ,  0 ,  100 ,  10 ) ,  0 ) ; 
0 commit comments