diff options
author | James M Snell <jasnell@gmail.com> | 2017-08-05 11:53:32 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-08-07 22:22:59 -0700 |
commit | 4da8b99a74c9d00a3733d50c6348750360bf1c40 (patch) | |
tree | 3daeef079a89e2bbc883526692fa857837ee1abf /test | |
parent | 80ebb4282d29733fefbcee8deb9cc70348eace16 (diff) | |
download | android-node-v8-4da8b99a74c9d00a3733d50c6348750360bf1c40.tar.gz android-node-v8-4da8b99a74c9d00a3733d50c6348750360bf1c40.tar.bz2 android-node-v8-4da8b99a74c9d00a3733d50c6348750360bf1c40.zip |
console: coerce label to string in console.time()
Per the console spec, the label in console.time() is a string.
Per the console spec, the default value of label is `'default'`.
PR-URL: https://github.com/nodejs/node/pull/14643
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-console.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index bca70467c0..10e1aa0ff2 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -42,6 +42,12 @@ assert.doesNotThrow(function() { console.timeEnd('label'); }); +assert.throws(() => console.time(Symbol('test')), + /^TypeError: Cannot convert a Symbol value to a string$/); +assert.throws(() => console.timeEnd(Symbol('test')), + /^TypeError: Cannot convert a Symbol value to a string$/); + + // an Object with a custom .inspect() function const custom_inspect = { foo: 'bar', inspect: () => 'inspect' }; @@ -103,6 +109,20 @@ console.timeEnd('constructor'); console.time('hasOwnProperty'); console.timeEnd('hasOwnProperty'); +// verify that values are coerced to strings +console.time([]); +console.timeEnd([]); +console.time({}); +console.timeEnd({}); +console.time(null); +console.timeEnd(null); +console.time(undefined); +console.timeEnd('default'); +console.time('default'); +console.timeEnd(); +console.time(NaN); +console.timeEnd(NaN); + assert.strictEqual(strings.length, process.stdout.writeTimes); assert.strictEqual(errStrings.length, process.stderr.writeTimes); common.restoreStdout(); |