@@ -65,38 +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 . 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+ } ) ;
102119} ) ) ;
0 commit comments