@@ -65,60 +65,55 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
6565 assert . fail ( err ) ;
6666 }
6767 if ( stats ) {
68- console . dir ( stats ) ;
6968 assert . ok ( stats . mtime instanceof Date ) ;
7069 }
7170 fs . close ( fd , assert . ifError ) ;
7271} ) ) ;
7372
74- console . log ( `stating: ${ __filename } ` ) ;
7573fs . stat ( __filename , common . mustCall ( function ( err , s ) {
7674 assert . ifError ( err ) ;
77-
78- console . dir ( s ) ;
79-
80- console . log ( `isDirectory: ${ JSON . stringify ( s . isDirectory ( ) ) } ` ) ;
8175 assert . strictEqual ( false , s . isDirectory ( ) ) ;
82-
83- console . log ( `isFile: ${ JSON . stringify ( s . isFile ( ) ) } ` ) ;
8476 assert . strictEqual ( true , s . isFile ( ) ) ;
85-
86- console . log ( `isSocket: ${ JSON . stringify ( s . isSocket ( ) ) } ` ) ;
8777 assert . strictEqual ( false , s . isSocket ( ) ) ;
88-
89- console . log ( `isBlockDevice: ${ JSON . stringify ( s . isBlockDevice ( ) ) } ` ) ;
9078 assert . strictEqual ( false , s . isBlockDevice ( ) ) ;
91-
92- console . log ( `isCharacterDevice: ${ JSON . stringify ( s . isCharacterDevice ( ) ) } ` ) ;
9379 assert . strictEqual ( false , s . isCharacterDevice ( ) ) ;
94-
95- console . log ( `isFIFO: ${ JSON . stringify ( s . isFIFO ( ) ) } ` ) ;
9680 assert . strictEqual ( false , s . isFIFO ( ) ) ;
97-
98- console . log ( `isSymbolicLink: ${ JSON . stringify ( s . isSymbolicLink ( ) ) } ` ) ;
9981 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 ) ) ;
10982 const keys = [
11083 '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'
11492 ] ;
11593 if ( ! common . isWindows ) {
11694 keys . push ( 'blocks' , 'blksize' ) ;
95+ numberFields . push ( 'blocks' , 'blksize' ) ;
11796 }
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 ) ) ;
118107 keys . forEach ( function ( k ) {
119108 assert . ok (
120- json [ k ] !== undefined && json [ k ] !== null ,
109+ parsed [ k ] !== undefined && parsed [ k ] !== null ,
121110 k + ' should not be null or undefined'
122111 ) ;
123112 } ) ;
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+ } ) ;
124119} ) ) ;
0 commit comments