diff options
author | Luca Maraschi <luca.maraschi@gmail.com> | 2017-03-17 17:07:19 +0100 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-03-21 22:31:04 -0700 |
commit | eed87b1637d64340856bb7f77db899f5283ca84f (patch) | |
tree | 65423aa3b6b3eda861b9aa115229de6798ec92bc /test/parallel/test-fs-timestamp-parsing-error.js | |
parent | ae8a8691e65c90053c3e996c14fd221b61f3effc (diff) | |
download | android-node-v8-eed87b1637d64340856bb7f77db899f5283ca84f.tar.gz android-node-v8-eed87b1637d64340856bb7f77db899f5283ca84f.tar.bz2 android-node-v8-eed87b1637d64340856bb7f77db899f5283ca84f.zip |
fs: (+/-)Infinity and NaN invalid unixtimestamp
Infinity and NaN are currently considered valid input when generating a
unix time stamp but are defaulted arbitrarly to Date.now()/1000. This
PR removes this behaviour and throw an exception like all the other
invalid input types.
PR-URL: https://github.com/nodejs/node/pull/11919
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-timestamp-parsing-error.js')
-rw-r--r-- | test/parallel/test-fs-timestamp-parsing-error.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/parallel/test-fs-timestamp-parsing-error.js b/test/parallel/test-fs-timestamp-parsing-error.js index 321f80b269..42bbe45d51 100644 --- a/test/parallel/test-fs-timestamp-parsing-error.js +++ b/test/parallel/test-fs-timestamp-parsing-error.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -const assert = require('assert'); const fs = require('fs'); +const assert = require('assert'); -[undefined, null, []].forEach((input) => { +[Infinity, -Infinity, NaN].forEach((input) => { assert.throws(() => fs._toUnixTimestamp(input), new RegExp('^Error: Cannot parse time: ' + input + '$')); }); @@ -11,6 +11,7 @@ const fs = require('fs'); assert.throws(() => fs._toUnixTimestamp({}), /^Error: Cannot parse time: \[object Object\]$/); -[1, '1', Date.now(), -1, '-1', Infinity].forEach((input) => { +const okInputs = [1, -1, '1', '-1', Date.now()]; +okInputs.forEach((input) => { assert.doesNotThrow(() => fs._toUnixTimestamp(input)); }); |