You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jh...@apache.org on 2013/02/11 04:29:11 UTC
[4/5] git commit: Webkit-compatible console.log() with
Node.js-compatible util.format()
Webkit-compatible console.log() with Node.js-compatible util.format()
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e45c689d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e45c689d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e45c689d
Branch: refs/heads/1676-feature-console_log
Commit: e45c689d9f256190e88b860fa2f689249204d5ad
Parents: 7d16962
Author: Jason Smith (work) <jh...@iriscouch.com>
Authored: Fri Feb 1 14:00:00 2013 +0000
Committer: Jason Smith (work) <jh...@iriscouch.com>
Committed: Mon Feb 11 02:20:55 2013 +0000
----------------------------------------------------------------------
share/Makefile.am | 2 ++
share/server/loop.js | 2 ++
share/www/script/test/design_docs.js | 15 +++++++++++++++
3 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e45c689d/share/Makefile.am
----------------------------------------------------------------------
diff --git a/share/Makefile.am b/share/Makefile.am
index 876c701..e055c00 100644
--- a/share/Makefile.am
+++ b/share/Makefile.am
@@ -15,9 +15,11 @@ SUBDIRS = doc
JS_FILE = server/main.js
JS_FILE_COMPONENTS = \
+ server/console.js \
server/json2.js \
server/filter.js \
server/mimeparse.js \
+ server/nodejs_util.js \
server/render.js \
server/state.js \
server/util.js \
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e45c689d/share/server/loop.js
----------------------------------------------------------------------
diff --git a/share/server/loop.js b/share/server/loop.js
index fcd016f..3aec8cb 100644
--- a/share/server/loop.js
+++ b/share/server/loop.js
@@ -20,6 +20,8 @@ function init_sandbox() {
sandbox.emit = Views.emit;
sandbox.sum = Views.sum;
sandbox.log = log;
+ sandbox.console = Console;
+ sandbox.util = Util;
sandbox.toJSON = Couch.toJSON;
sandbox.JSON = JSON;
sandbox.provides = Mime.provides;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e45c689d/share/www/script/test/design_docs.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js
index dd38858..be5db6d 100644
--- a/share/www/script/test/design_docs.js
+++ b/share/www/script/test/design_docs.js
@@ -162,6 +162,16 @@ couchTests.design_docs = function(debug) {
}
},
shows: {
+ logging:
+ (function() {
+ try {
+ var log = typeof console.log;
+ var format = typeof util.format;
+ return util.format("%d types: %s and %j", 2, log, format);
+ } catch (er) {
+ return '{}';
+ }
+ }).toString(),
simple:
(function() {
return 'ok';
@@ -225,6 +235,11 @@ couchTests.design_docs = function(debug) {
T(xhr.status == 200);
TEquals("ok", xhr.responseText, 'query server used wrong ddoc');
+ // Test the console.log() and util.format() API.
+ xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_show/logging");
+ T(xhr.status == 200);
+ TEquals(xhr.responseText, '2 types: function and "function"');
+
// test commonjs require
xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_show/requirey");
T(xhr.status == 200);