@@ -65,38 +65,55 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
65
65
assert . fail ( err ) ;
66
66
}
67
67
if ( stats ) {
68
- console . dir ( stats ) ;
69
68
assert . ok ( stats . mtime instanceof Date ) ;
70
69
}
71
70
fs . close ( fd , assert . ifError ) ;
72
71
} ) ) ;
73
72
74
- console . log ( `stating: ${ __filename } ` ) ;
75
73
fs . stat ( __filename , common . mustCall ( function ( err , s ) {
76
74
assert . ifError ( err ) ;
77
-
78
- console . dir ( s ) ;
79
-
80
- console . log ( `isDirectory: ${ JSON . stringify ( s . isDirectory ( ) ) } ` ) ;
81
75
assert . strictEqual ( false , s . isDirectory ( ) ) ;
82
-
83
- console . log ( `isFile: ${ JSON . stringify ( s . isFile ( ) ) } ` ) ;
84
76
assert . strictEqual ( true , s . isFile ( ) ) ;
85
-
86
- console . log ( `isSocket: ${ JSON . stringify ( s . isSocket ( ) ) } ` ) ;
87
77
assert . strictEqual ( false , s . isSocket ( ) ) ;
88
-
89
- console . log ( `isBlockDevice: ${ JSON . stringify ( s . isBlockDevice ( ) ) } ` ) ;
90
78
assert . strictEqual ( false , s . isBlockDevice ( ) ) ;
91
-
92
- console . log ( `isCharacterDevice: ${ JSON . stringify ( s . isCharacterDevice ( ) ) } ` ) ;
93
79
assert . strictEqual ( false , s . isCharacterDevice ( ) ) ;
94
-
95
- console . log ( `isFIFO: ${ JSON . stringify ( s . isFIFO ( ) ) } ` ) ;
96
80
assert . strictEqual ( false , s . isFIFO ( ) ) ;
97
-
98
- console . log ( `isSymbolicLink: ${ JSON . stringify ( s . isSymbolicLink ( ) ) } ` ) ;
99
81
assert . strictEqual ( false , s . isSymbolicLink ( ) ) ;
100
-
101
- assert . ok ( s . mtime instanceof Date ) ;
82
+ const keys = [
83
+ 'dev' , 'mode' , 'nlink' , 'uid' ,
84
+ 'gid' , 'rdev' , 'ino' , 'size' ,
85
+ 'atime' , 'mtime' , 'ctime' , 'birthtime' ,
86
+ 'atimeMs' , 'mtimeMs' , 'ctimeMs' , 'birthtimeMs'
87
+ ] ;
88
+ if ( ! common . isWindows ) {
89
+ keys . push ( 'blocks' , 'blksize' ) ;
90
+ }
91
+ const numberFields = [
92
+ 'dev' , 'mode' , 'nlink' , 'uid' , 'gid' , 'rdev' , 'ino' , 'size' ,
93
+ 'atimeMs' , 'mtimeMs' , 'ctimeMs' , 'birthtimeMs'
94
+ ] ;
95
+ const dateFields = [ 'atime' , 'mtime' , 'ctime' , 'birthtime' ] ;
96
+ keys . forEach ( function ( k ) {
97
+ assert . ok ( k in s , `${ k } should be in Stats` ) ;
98
+ assert . notStrictEqual ( s [ k ] , undefined , `${ k } should not be undefined` ) ;
99
+ assert . notStrictEqual ( s [ k ] , null , `${ k } should not be null` ) ;
100
+ } ) ;
101
+ numberFields . forEach ( ( k ) => {
102
+ assert . strictEqual ( typeof s [ k ] , 'number' , `${ k } should be a number` ) ;
103
+ } ) ;
104
+ dateFields . forEach ( ( k ) => {
105
+ assert . ok ( s [ k ] instanceof Date , `${ k } should be a Date` ) ;
106
+ } ) ;
107
+ const jsonString = JSON . stringify ( s ) ;
108
+ const parsed = JSON . parse ( jsonString ) ;
109
+ keys . forEach ( function ( k ) {
110
+ assert . notStrictEqual ( parsed [ k ] , undefined , `${ k } should not be undefined` ) ;
111
+ assert . notStrictEqual ( parsed [ k ] , null , `${ k } should not be null` ) ;
112
+ } ) ;
113
+ numberFields . forEach ( ( k ) => {
114
+ assert . strictEqual ( typeof parsed [ k ] , 'number' , `${ k } should be a number` ) ;
115
+ } ) ;
116
+ dateFields . forEach ( ( k ) => {
117
+ assert . strictEqual ( typeof parsed [ k ] , 'string' , `${ k } should be a string` ) ;
118
+ } ) ;
102
119
} ) ) ;
0 commit comments