@@ -18,10 +18,10 @@ const s = '南越国是前203年至前111年存在于岭南地区的一个国家
1818 '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n' ;
1919
2020fs . writeFile ( filename , s , common . mustCall ( function ( e ) {
21- if ( e ) throw e ;
21+ assert . ifError ( e ) ;
2222
2323 fs . readFile ( filename , common . mustCall ( function ( e , buffer ) {
24- if ( e ) throw e ;
24+ assert . ifError ( e ) ;
2525 assert . strictEqual ( Buffer . byteLength ( s ) , buffer . length ) ;
2626 } ) ) ;
2727} ) ) ;
@@ -31,10 +31,10 @@ const filename2 = join(common.tmpDir, 'test2.txt');
3131const buf = Buffer . from ( s , 'utf8' ) ;
3232
3333fs . writeFile ( filename2 , buf , common . mustCall ( function ( e ) {
34- if ( e ) throw e ;
34+ assert . ifError ( e ) ;
3535
3636 fs . readFile ( filename2 , common . mustCall ( function ( e , buffer ) {
37- if ( e ) throw e ;
37+ assert . ifError ( e ) ;
3838
3939 assert . strictEqual ( buf . length , buffer . length ) ;
4040 } ) ) ;
@@ -45,7 +45,7 @@ const filename3 = join(common.tmpDir, 'test3.txt');
4545
4646const m = 0o600 ;
4747fs . writeFile ( filename3 , n , { mode : m } , common . mustCall ( function ( e ) {
48- if ( e ) throw e ;
48+ assert . ifError ( e ) ;
4949
5050 // windows permissions aren't unix
5151 if ( ! common . isWindows ) {
@@ -54,7 +54,7 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
5454 }
5555
5656 fs . readFile ( filename3 , common . mustCall ( function ( e , buffer ) {
57- if ( e ) throw e ;
57+ assert . ifError ( e ) ;
5858
5959 assert . strictEqual ( Buffer . byteLength ( '' + n ) , buffer . length ) ;
6060 } ) ) ;
@@ -64,16 +64,16 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
6464const filename4 = join ( common . tmpDir , 'test4.txt' ) ;
6565
6666fs . open ( filename4 , 'w+' , common . mustCall ( function ( e , fd ) {
67- if ( e ) throw e ;
67+ assert . ifError ( e ) ;
6868
6969 fs . writeFile ( fd , s , common . mustCall ( function ( e ) {
70- if ( e ) throw e ;
70+ assert . ifError ( e ) ;
7171
7272 fs . close ( fd , common . mustCall ( function ( e ) {
73- if ( e ) throw e ;
73+ assert . ifError ( e ) ;
7474
7575 fs . readFile ( filename4 , common . mustCall ( function ( e , buffer ) {
76- if ( e ) throw e ;
76+ assert . ifError ( e ) ;
7777
7878 assert . strictEqual ( Buffer . byteLength ( s ) , buffer . length ) ;
7979 } ) ) ;
0 commit comments