From 07d4183e8c3d7ba726228be9125a65b6a8bd3be6 Mon Sep 17 00:00:00 2001 From: aks- Date: Wed, 21 Oct 2015 22:04:02 +0530 Subject: [PATCH] console: Add noop impls of methods required in spec - this conforms to the following spec - https://github.com/DeveloperToolsWG/console-object/blob/master/api.md --- doc/api/console.markdown | 18 +++++++++++++++ lib/console.js | 42 +++++++++++++++++++++++++++++++++++ test/parallel/test-console.js | 30 +++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/doc/api/console.markdown b/doc/api/console.markdown index 6e2de6071e64a2..75e55389a0b062 100644 --- a/doc/api/console.markdown +++ b/doc/api/console.markdown @@ -105,6 +105,24 @@ to the current position. Similar to [assert.ok()][], but the error message is formatted as `util.format(message...)`. +### Compatibility functions + +NOTE: The following functions are defined for compatibility purpose, and are not expected to do anything + +* `console.group` +* `console.groupCollapsed` +* `console.groupEnd` +* `console.clear` +* `console.count` +* `console.dirxml` +* `console.isIndependentlyComposed` +* `console.table` +* `console.profile` +* `console.profileEnd` +* `console.timeline` +* `console.timelineEnd` +* `console.timeStamp` + ## Class: Console diff --git a/lib/console.js b/lib/console.js index d2b4f3fc5b59be..350a14038dba57 100644 --- a/lib/console.js +++ b/lib/console.js @@ -90,5 +90,47 @@ Console.prototype.assert = function(expression) { }; +Console.prototype.group = noop; + + +Console.prototype.groupCollapsed = noop; + + +Console.prototype.groupEnd = noop; + + +Console.prototype.clear = noop; + + +Console.prototype.count = noop; + + +Console.prototype.dirxml = noop; + + +Console.prototype.isIndependentlyComposed = noop; + + +Console.prototype.table = noop; + + +Console.prototype.profile = noop; + + +Console.prototype.profileEnd = noop; + + +Console.prototype.timeline = noop; + + +Console.prototype.timelineEnd = noop; + + +Console.prototype.timeStamp = noop; + + +function noop() {} + + module.exports = new Console(process.stdout, process.stderr); module.exports.Console = Console; diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index f8a927398034cb..f0e93027ddff32 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -17,6 +17,36 @@ assert.doesNotThrow(function() { console.timeEnd('label'); }); +assert.doesNotThrow(function() { + console.group('test'); + console.groupEnd(); +}); + +assert.doesNotThrow(function() { + console.groupCollapsed('test'); + console.groupEnd(); +}); + +assert.doesNotThrow(console.clear); + +assert.doesNotThrow(console.count); + +assert.doesNotThrow(console.dirxml); + +assert.doesNotThrow(console.exception); + +assert.doesNotThrow(console.isIndependentlyComposed); + +assert.doesNotThrow(console.profile); + +assert.doesNotThrow(console.profileEnd); + +assert.doesNotThrow(console.timeline); + +assert.doesNotThrow(console.timelineEnd); + +assert.doesNotThrow(console.timeStamp); + // an Object with a custom .inspect() function var custom_inspect = { foo: 'bar', inspect: function() { return 'inspect'; } };