| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dec5900 commit 38bdfb0
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,11 +4,11 @@ var assert = require('assert'); | |||
| 4 | 4 | var util = require('util'); | |
| 5 | 5 | var fs = require('fs'); | |
| 6 | 6 | ||
| 7 | - var tests_ok = 0; | ||
| 8 | - var tests_run = 0; | ||
| 7 | + let tests_ok = 0; | ||
| 8 | + let tests_run = 0; | ||
| 9 | 9 | ||
| 10 | 10 | function stat_resource(resource) { | |
| 11 | - if (typeof resource == 'string') { | ||
| 11 | + if (typeof resource === 'string') { | ||
| 12 | 12 | return fs.statSync(resource); | |
| 13 | 13 | } else { | |
| 14 | 14 | // ensure mtime has been written to disk | |
@@ -19,8 +19,8 @@ function stat_resource(resource) { | |||
| 19 | 19 | ||
| 20 | 20 | function check_mtime(resource, mtime) { | |
| 21 | 21 | 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); | ||
| 24 | 24 | // check up to single-second precision | |
| 25 | 25 | // sub-second precision is OS and fs dependant | |
| 26 | 26 | return mtime - real_mtime < 2; | |
@@ -46,9 +46,9 @@ function expect_ok(syscall, resource, err, atime, mtime) { | |||
| 46 | 46 | // the tests assume that __filename belongs to the user running the tests | |
| 47 | 47 | // this should be a fairly safe assumption; testing against a temp file | |
| 48 | 48 | // would be even better though (node doesn't have such functionality yet) | |
| 49 | - function runTest(atime, mtime, callback) { | ||
| 49 | + function testIt(atime, mtime, callback) { | ||
| 50 | 50 | ||
| 51 | - var fd; | ||
| 51 | + let fd; | ||
| 52 | 52 | // | |
| 53 | 53 | // test synchronized code paths, these functions throw on failure | |
| 54 | 54 | // | |
@@ -67,8 +67,7 @@ function runTest(atime, mtime, callback) { | |||
| 67 | 67 | expect_errno('futimesSync', fd, ex, 'ENOSYS'); | |
| 68 | 68 | } | |
| 69 | 69 | ||
| 70 | - var err; | ||
| 71 | - err = undefined; | ||
| 70 | + let err = undefined; | ||
| 72 | 71 | try { | |
| 73 | 72 | fs.utimesSync('foobarbaz', atime, mtime); | |
| 74 | 73 | } catch (ex) { | |
@@ -90,10 +89,10 @@ function runTest(atime, mtime, callback) { | |||
| 90 | 89 | // | |
| 91 | 90 | // test async code paths | |
| 92 | 91 | // | |
| 93 | - fs.utimes(__filename, atime, mtime, function(err) { | ||
| 92 | + fs.utimes(__filename, atime, mtime, common.mustCall(function(err) { | ||
| 94 | 93 | expect_ok('utimes', __filename, err, atime, mtime); | |
| 95 | 94 | ||
| 96 | - fs.utimes('foobarbaz', atime, mtime, function(err) { | ||
| 95 | + fs.utimes('foobarbaz', atime, mtime, common.mustCall(function(err) { | ||
| 97 | 96 | expect_errno('utimes', 'foobarbaz', err, 'ENOENT'); | |
| 98 | 97 | ||
| 99 | 98 | // don't close this fd | |
@@ -103,34 +102,36 @@ function runTest(atime, mtime, callback) { | |||
| 103 | 102 | fd = fs.openSync(__filename, 'r'); | |
| 104 | 103 | } | |
| 105 | 104 | ||
| 106 | - fs.futimes(fd, atime, mtime, function(err) { | ||
| 105 | + fs.futimes(fd, atime, mtime, common.mustCall(function(err) { | ||
| 107 | 106 | expect_ok('futimes', fd, err, atime, mtime); | |
| 108 | 107 | ||
| 109 | - fs.futimes(-1, atime, mtime, function(err) { | ||
| 108 | + fs.futimes(-1, atime, mtime, common.mustCall(function(err) { | ||
| 110 | 109 | expect_errno('futimes', -1, err, 'EBADF'); | |
| 111 | 110 | syncTests(); | |
| 112 | 111 | callback(); | |
| 113 | - }); | ||
| 112 | + })); | ||
| 114 | 113 | tests_run++; | |
| 115 | - }); | ||
| 114 | + })); | ||
| 116 | 115 | tests_run++; | |
| 117 | - }); | ||
| 116 | + })); | ||
| 118 | 117 | tests_run++; | |
| 119 | - }); | ||
| 118 | + })); | ||
| 120 | 119 | tests_run++; | |
| 121 | 120 | } | |
| 122 | 121 | ||
| 123 | - var stats = fs.statSync(__filename); | ||
| 122 | + const stats = fs.statSync(__filename); | ||
| 124 | 123 | ||
| 125 | 124 | // run tests | |
| 125 | + const runTest = common.mustCall(testIt, 6); | ||
| 126 | + | ||
| 126 | 127 | runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() { | |
| 127 | 128 | runTest(new Date(), new Date(), function() { | |
| 128 | 129 | runTest(123456.789, 123456.789, function() { | |
| 129 | 130 | runTest(stats.mtime, stats.mtime, function() { | |
| 130 | 131 | runTest(NaN, Infinity, function() { | |
| 131 | - runTest('123456', -1, function() { | ||
| 132 | + runTest('123456', -1, common.mustCall(function() { | ||
| 132 | 133 | // done | |
| 133 | - }); | ||
| 134 | + })); | ||
| 134 | 135 | }); | |
| 135 | 136 | }); | |
| 136 | 137 | }); | |
@@ -140,5 +141,5 @@ runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() { | |||
| 140 | 141 | ||
| 141 | 142 | process.on('exit', function() { | |
| 142 | 143 | console.log('Tests run / ok:', tests_run, '/', tests_ok); | |
| 143 | - assert.equal(tests_ok, tests_run); | ||
| 144 | + assert.strictEqual(tests_ok, tests_run); | ||
| 144 | 145 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments