@@ -4,11 +4,11 @@ var assert = require('assert');
44var util = require ( 'util' ) ;
55var fs = require ( 'fs' ) ;
66
7- var tests_ok = 0 ;
8- var tests_run = 0 ;
7+ let tests_ok = 0 ;
8+ let tests_run = 0 ;
99
1010function stat_resource ( resource ) {
11- if ( typeof resource == 'string' ) {
11+ if ( typeof resource === 'string' ) {
1212 return fs . statSync ( resource ) ;
1313 } else {
1414 // ensure mtime has been written to disk
@@ -19,8 +19,8 @@ function stat_resource(resource) {
1919
2020function check_mtime ( resource , mtime ) {
2121 mtime = fs . _toUnixTimestamp ( mtime ) ;
22- var stats = stat_resource ( resource ) ;
23- var real_mtime = fs . _toUnixTimestamp ( stats . mtime ) ;
22+ const stats = stat_resource ( resource ) ;
23+ const real_mtime = fs . _toUnixTimestamp ( stats . mtime ) ;
2424 // check up to single-second precision
2525 // sub-second precision is OS and fs dependant
2626 return mtime - real_mtime < 2 ;
@@ -46,9 +46,9 @@ function expect_ok(syscall, resource, err, atime, mtime) {
4646// the tests assume that __filename belongs to the user running the tests
4747// this should be a fairly safe assumption; testing against a temp file
4848// would be even better though (node doesn't have such functionality yet)
49- function runTest ( atime , mtime , callback ) {
49+ function testIt ( atime , mtime , callback ) {
5050
51- var fd ;
51+ let fd ;
5252 //
5353 // test synchronized code paths, these functions throw on failure
5454 //
@@ -67,8 +67,7 @@ function runTest(atime, mtime, callback) {
6767 expect_errno ( 'futimesSync' , fd , ex , 'ENOSYS' ) ;
6868 }
6969
70- var err ;
71- err = undefined ;
70+ let err = undefined ;
7271 try {
7372 fs . utimesSync ( 'foobarbaz' , atime , mtime ) ;
7473 } catch ( ex ) {
@@ -90,10 +89,10 @@ function runTest(atime, mtime, callback) {
9089 //
9190 // test async code paths
9291 //
93- fs . utimes ( __filename , atime , mtime , function ( err ) {
92+ fs . utimes ( __filename , atime , mtime , common . mustCall ( function ( err ) {
9493 expect_ok ( 'utimes' , __filename , err , atime , mtime ) ;
9594
96- fs . utimes ( 'foobarbaz' , atime , mtime , function ( err ) {
95+ fs . utimes ( 'foobarbaz' , atime , mtime , common . mustCall ( function ( err ) {
9796 expect_errno ( 'utimes' , 'foobarbaz' , err , 'ENOENT' ) ;
9897
9998 // don't close this fd
@@ -103,34 +102,36 @@ function runTest(atime, mtime, callback) {
103102 fd = fs . openSync ( __filename , 'r' ) ;
104103 }
105104
106- fs . futimes ( fd , atime , mtime , function ( err ) {
105+ fs . futimes ( fd , atime , mtime , common . mustCall ( function ( err ) {
107106 expect_ok ( 'futimes' , fd , err , atime , mtime ) ;
108107
109- fs . futimes ( - 1 , atime , mtime , function ( err ) {
108+ fs . futimes ( - 1 , atime , mtime , common . mustCall ( function ( err ) {
110109 expect_errno ( 'futimes' , - 1 , err , 'EBADF' ) ;
111110 syncTests ( ) ;
112111 callback ( ) ;
113- } ) ;
112+ } ) ) ;
114113 tests_run ++ ;
115- } ) ;
114+ } ) ) ;
116115 tests_run ++ ;
117- } ) ;
116+ } ) ) ;
118117 tests_run ++ ;
119- } ) ;
118+ } ) ) ;
120119 tests_run ++ ;
121120}
122121
123- var stats = fs . statSync ( __filename ) ;
122+ const stats = fs . statSync ( __filename ) ;
124123
125124// run tests
125+ const runTest = common . mustCall ( testIt , 6 ) ;
126+
126127runTest ( new Date ( '1982-09-10 13:37' ) , new Date ( '1982-09-10 13:37' ) , function ( ) {
127128 runTest ( new Date ( ) , new Date ( ) , function ( ) {
128129 runTest ( 123456.789 , 123456.789 , function ( ) {
129130 runTest ( stats . mtime , stats . mtime , function ( ) {
130131 runTest ( NaN , Infinity , function ( ) {
131- runTest ( '123456' , - 1 , function ( ) {
132+ runTest ( '123456' , - 1 , common . mustCall ( function ( ) {
132133 // done
133- } ) ;
134+ } ) ) ;
134135 } ) ;
135136 } ) ;
136137 } ) ;
@@ -140,5 +141,5 @@ runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() {
140141
141142process . on ( 'exit' , function ( ) {
142143 console . log ( 'Tests run / ok:' , tests_run , '/' , tests_ok ) ;
143- assert . equal ( tests_ok , tests_run ) ;
144+ assert . strictEqual ( tests_ok , tests_run ) ;
144145} ) ;
0 commit comments