diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2017-01-12 20:03:29 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2017-01-23 21:30:18 +0800 |
commit | a647d82f83ad5ddad5db7be2cc24c3d686121792 (patch) | |
tree | 12bac723888bc85f29247f7942f5e2c247943a28 /test/parallel/test-process-hrtime.js | |
parent | 9fcd842279d8aee020c0a125db80641bb107ca36 (diff) | |
download | android-node-v8-a647d82f83ad5ddad5db7be2cc24c3d686121792.tar.gz android-node-v8-a647d82f83ad5ddad5db7be2cc24c3d686121792.tar.bz2 android-node-v8-a647d82f83ad5ddad5db7be2cc24c3d686121792.zip |
process: improve process.hrtime
* Add benchmarks for diffing a previous result
* Improvements to the documentation, including type annotation
* Update the outdated comments in src/node.cc, improve comments
in lib/internal/process.js
* Check the argument is an Array Tuple with length 2
PR-URL: https://github.com/nodejs/node/pull/10764
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'test/parallel/test-process-hrtime.js')
-rw-r--r-- | test/parallel/test-process-hrtime.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/parallel/test-process-hrtime.js b/test/parallel/test-process-hrtime.js index faa598d0a5..db8700d3e6 100644 --- a/test/parallel/test-process-hrtime.js +++ b/test/parallel/test-process-hrtime.js @@ -15,14 +15,21 @@ validateTuple(process.hrtime(tuple)); assert.throws(() => { process.hrtime(1); }, /^TypeError: process.hrtime\(\) only accepts an Array tuple$/); +assert.throws(() => { + process.hrtime([]); +}, /^TypeError: process.hrtime\(\) only accepts an Array tuple$/); +assert.throws(() => { + process.hrtime([1]); +}, /^TypeError: process.hrtime\(\) only accepts an Array tuple$/); +assert.throws(() => { + process.hrtime([1, 2, 3]); +}, /^TypeError: process.hrtime\(\) only accepts an Array tuple$/); function validateTuple(tuple) { assert(Array.isArray(tuple)); assert.strictEqual(tuple.length, 2); - tuple.forEach((v) => { - assert.strictEqual(typeof v, 'number'); - assert.strictEqual(isFinite(v), true); - }); + assert(Number.isInteger(tuple[0])); + assert(Number.isInteger(tuple[1])); } const diff = process.hrtime([0, 1e9 - 1]); |