@@ -65,60 +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 . atime instanceof Date ) ;
102
- assert . ok ( s . mtime instanceof Date ) ;
103
- assert . ok ( s . ctime instanceof Date ) ;
104
- assert . ok ( s . birthtime instanceof Date ) ;
105
- } ) ) ;
106
-
107
- fs . stat ( __filename , common . mustCall ( function ( err , s ) {
108
- const json = JSON . parse ( JSON . stringify ( s ) ) ;
109
82
const keys = [
110
83
'dev' , 'mode' , 'nlink' , 'uid' ,
111
- 'gid' , 'rdev' , 'ino' ,
112
- 'size' , 'atime' , 'mtime' ,
113
- 'ctime' , 'birthtime'
84
+ 'gid' , 'rdev' , 'ino' , 'size' ,
85
+ 'atimeMs' , 'mtimeMs' , 'ctimeMs' , 'birthtimeMs' ,
86
+ 'atime' , 'mtime' , 'ctime' , 'birthtime'
87
+ ] ;
88
+ const dateFields = [ 'atime' , 'mtime' , 'ctime' , 'birthtime' ] ;
89
+ const numberFields = [
90
+ 'dev' , 'mode' , 'nlink' , 'uid' , 'gid' , 'rdev' , 'ino' , 'size' ,
91
+ 'atimeMs' , 'mtimeMs' , 'ctimeMs' , 'birthtimeMs'
114
92
] ;
115
93
if ( ! common . isWindows ) {
116
94
keys . push ( 'blocks' , 'blksize' ) ;
95
+ numberFields . push ( 'blocks' , 'blksize' ) ;
117
96
}
97
+ const actualKeys = Object . keys ( s ) ;
98
+ keys . forEach ( ( k ) => assert . strictEqual ( actualKeys . includes ( k ) , true ,
99
+ `${ k } should a field of s` ) ) ;
100
+ numberFields . forEach ( ( k ) => {
101
+ assert . strictEqual ( typeof s [ k ] , 'number' , `${ k } should be a number` ) ;
102
+ } ) ;
103
+ dateFields . forEach ( ( k ) => {
104
+ assert . ok ( s [ k ] instanceof Date , `${ k } should be a Date` ) ;
105
+ } ) ;
106
+ const parsed = JSON . parse ( JSON . stringify ( s ) ) ;
118
107
keys . forEach ( function ( k ) {
119
108
assert . ok (
120
- json [ k ] !== undefined && json [ k ] !== null ,
109
+ parsed [ k ] !== undefined && parsed [ k ] !== null ,
121
110
k + ' should not be null or undefined'
122
111
) ;
123
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
+ } ) ;
124
119
} ) ) ;
0 commit comments