@@ -18,10 +18,10 @@ const s = '南越国是前203年至前111年存在于岭南地区的一个国家
18
18
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n' ;
19
19
20
20
fs . writeFile ( filename , s , common . mustCall ( function ( e ) {
21
- if ( e ) throw e ;
21
+ assert . ifError ( e ) ;
22
22
23
23
fs . readFile ( filename , common . mustCall ( function ( e , buffer ) {
24
- if ( e ) throw e ;
24
+ assert . ifError ( e ) ;
25
25
assert . strictEqual ( Buffer . byteLength ( s ) , buffer . length ) ;
26
26
} ) ) ;
27
27
} ) ) ;
@@ -31,10 +31,10 @@ const filename2 = join(common.tmpDir, 'test2.txt');
31
31
const buf = Buffer . from ( s , 'utf8' ) ;
32
32
33
33
fs . writeFile ( filename2 , buf , common . mustCall ( function ( e ) {
34
- if ( e ) throw e ;
34
+ assert . ifError ( e ) ;
35
35
36
36
fs . readFile ( filename2 , common . mustCall ( function ( e , buffer ) {
37
- if ( e ) throw e ;
37
+ assert . ifError ( e ) ;
38
38
39
39
assert . strictEqual ( buf . length , buffer . length ) ;
40
40
} ) ) ;
@@ -45,7 +45,7 @@ const filename3 = join(common.tmpDir, 'test3.txt');
45
45
46
46
const m = 0o600 ;
47
47
fs . writeFile ( filename3 , n , { mode : m } , common . mustCall ( function ( e ) {
48
- if ( e ) throw e ;
48
+ assert . ifError ( e ) ;
49
49
50
50
// windows permissions aren't unix
51
51
if ( ! common . isWindows ) {
@@ -54,7 +54,7 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
54
54
}
55
55
56
56
fs . readFile ( filename3 , common . mustCall ( function ( e , buffer ) {
57
- if ( e ) throw e ;
57
+ assert . ifError ( e ) ;
58
58
59
59
assert . strictEqual ( Buffer . byteLength ( '' + n ) , buffer . length ) ;
60
60
} ) ) ;
@@ -64,16 +64,16 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) {
64
64
const filename4 = join ( common . tmpDir , 'test4.txt' ) ;
65
65
66
66
fs . open ( filename4 , 'w+' , common . mustCall ( function ( e , fd ) {
67
- if ( e ) throw e ;
67
+ assert . ifError ( e ) ;
68
68
69
69
fs . writeFile ( fd , s , common . mustCall ( function ( e ) {
70
- if ( e ) throw e ;
70
+ assert . ifError ( e ) ;
71
71
72
72
fs . close ( fd , common . mustCall ( function ( e ) {
73
- if ( e ) throw e ;
73
+ assert . ifError ( e ) ;
74
74
75
75
fs . readFile ( filename4 , common . mustCall ( function ( e , buffer ) {
76
- if ( e ) throw e ;
76
+ assert . ifError ( e ) ;
77
77
78
78
assert . strictEqual ( Buffer . byteLength ( s ) , buffer . length ) ;
79
79
} ) ) ;
0 commit comments