2017-03-16 23:58:16 +01:00
|
|
|
'use strict';
|
2019-12-25 18:02:16 +01:00
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
2017-03-16 23:58:16 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2023-11-10 10:36:27 +01:00
|
|
|
for (const input of [Infinity, -Infinity, NaN]) {
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2017-08-26 07:46:47 -04:00
|
|
|
() => {
|
|
|
|
fs._toUnixTimestamp(input);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'TypeError'
|
2017-08-26 07:46:47 -04:00
|
|
|
});
|
2023-11-10 10:36:27 +01:00
|
|
|
}
|
2017-03-16 23:58:16 +01:00
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2017-08-26 07:46:47 -04:00
|
|
|
() => {
|
|
|
|
fs._toUnixTimestamp({});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'TypeError'
|
2017-08-26 07:46:47 -04:00
|
|
|
});
|
2017-03-16 23:58:16 +01:00
|
|
|
|
2017-03-17 17:07:19 +01:00
|
|
|
const okInputs = [1, -1, '1', '-1', Date.now()];
|
2023-11-10 10:36:27 +01:00
|
|
|
for (const input of okInputs) {
|
2018-02-09 02:32:04 +01:00
|
|
|
fs._toUnixTimestamp(input);
|
2023-11-10 10:36:27 +01:00
|
|
|
}
|