diff options
Diffstat (limited to 'src/mongo/shell/assert.js')
-rw-r--r-- | src/mongo/shell/assert.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js index ce2ec257763..20c8f2d481b 100644 --- a/src/mongo/shell/assert.js +++ b/src/mongo/shell/assert.js @@ -1,13 +1,13 @@ doassert = function(msg, obj) { // eval if msg is a function - if (typeof(msg) == "function") + if (typeof (msg) == "function") msg = msg(); - if (typeof(msg) == "object") + if (typeof (msg) == "object") msg = tojson(msg); if (jsTest.options().traceExceptions) { - if (typeof(msg) == "string" && msg.indexOf("assert") == 0) + if (typeof (msg) == "string" && msg.indexOf("assert") == 0) print(msg); else print("assert: " + msg); @@ -27,7 +27,6 @@ doassert = function(msg, obj) { // Sort doc/obj fields and return new sorted obj sortDoc = function(doc) { - // Helper to sort the elements of the array var sortElementsOfArray = function(arr) { var newArr = []; @@ -318,7 +317,7 @@ assert = (function() { var msgPrefix = "assert.soon failed: " + func; if (msg) { - if (typeof(msg) != "function") { + if (typeof (msg) != "function") { msgPrefix = "assert.soon failed, msg"; } } @@ -328,7 +327,7 @@ assert = (function() { interval = interval || 200; var last; while (1) { - if (typeof(func) == "string") { + if (typeof (func) == "string") { if (eval(func)) return; } else { @@ -418,7 +417,7 @@ assert = (function() { var start = new Date(); timeout = timeout || 30000; - if (typeof(f) == "string") { + if (typeof (f) == "string") { res = eval(f); } else { res = f(); @@ -929,7 +928,6 @@ assert = (function() { }; assert.gleOK = function(res, msg) { - var errMsg = null; if (!res) { @@ -950,7 +948,7 @@ assert = (function() { assert.gleSuccess = function(dbOrGLEDoc, msg) { var gle = dbOrGLEDoc instanceof DB ? dbOrGLEDoc.getLastErrorObj() : dbOrGLEDoc; if (gle.err) { - if (typeof(msg) == "function") + if (typeof (msg) == "function") msg = msg(gle); doassert(_buildAssertionMessage(msg, "getLastError not null: " + tojson(gle)), gle); } @@ -960,7 +958,7 @@ assert = (function() { assert.gleError = function(dbOrGLEDoc, msg) { var gle = dbOrGLEDoc instanceof DB ? dbOrGLEDoc.getLastErrorObj() : dbOrGLEDoc; if (!gle.err) { - if (typeof(msg) == "function") + if (typeof (msg) == "function") msg = msg(gle); doassert(_buildAssertionMessage(msg, "getLastError is null: " + tojson(gle))); } @@ -969,7 +967,7 @@ assert = (function() { assert.gleErrorCode = function(dbOrGLEDoc, code, msg) { var gle = dbOrGLEDoc instanceof DB ? dbOrGLEDoc.getLastErrorObj() : dbOrGLEDoc; if (!gle.err || gle.code != code) { - if (typeof(msg) == "function") + if (typeof (msg) == "function") msg = msg(gle); doassert(_buildAssertionMessage( msg, @@ -980,7 +978,7 @@ assert = (function() { assert.gleErrorRegex = function(dbOrGLEDoc, regex, msg) { var gle = dbOrGLEDoc instanceof DB ? dbOrGLEDoc.getLastErrorObj() : dbOrGLEDoc; if (!gle.err || !regex.test(gle.err)) { - if (typeof(msg) == "function") + if (typeof (msg) == "function") msg = msg(gle); doassert(_buildAssertionMessage( msg, |