summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/js_exceptions.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/js_exceptions.js')
-rw-r--r--jstests/noPassthrough/js_exceptions.js208
1 files changed, 104 insertions, 104 deletions
diff --git a/jstests/noPassthrough/js_exceptions.js b/jstests/noPassthrough/js_exceptions.js
index fe7cb4aa48f..27c7f6c2a41 100644
--- a/jstests/noPassthrough/js_exceptions.js
+++ b/jstests/noPassthrough/js_exceptions.js
@@ -3,120 +3,120 @@
*
*/
(function() {
- 'use strict';
- let tests = [
- {
- callback: function() {
- UUID("asdf");
- },
- match: "Error: Invalid UUID string: asdf :",
- stack: true,
+'use strict';
+let tests = [
+ {
+ callback: function() {
+ UUID("asdf");
},
- {
- callback: function() {
- throw {};
- },
- match: "uncaught exception: \\\[object Object\\\] :",
- stack: undefined,
+ match: "Error: Invalid UUID string: asdf :",
+ stack: true,
+ },
+ {
+ callback: function() {
+ throw {};
},
- {
- callback: function() {
- throw "asdf";
- },
- match: "uncaught exception: asdf",
- stack: false,
+ match: "uncaught exception: \\\[object Object\\\] :",
+ stack: undefined,
+ },
+ {
+ callback: function() {
+ throw "asdf";
},
- {
- callback: function() {
- throw 1;
- },
- match: "uncaught exception: 1",
- stack: false,
+ match: "uncaught exception: asdf",
+ stack: false,
+ },
+ {
+ callback: function() {
+ throw 1;
},
- {
- callback: function() {
- foo.bar();
- },
- match: "uncaught exception: ReferenceError: foo is not defined :",
- stack: true,
+ match: "uncaught exception: 1",
+ stack: false,
+ },
+ {
+ callback: function() {
+ foo.bar();
},
- {
- callback: function() {
- throw function() {};
- },
- match: "function\\\(\\\) {} :",
- stack: undefined,
+ match: "uncaught exception: ReferenceError: foo is not defined :",
+ stack: true,
+ },
+ {
+ callback: function() {
+ throw function() {};
},
- {
- callback: function() {
- try {
- UUID("asdf");
- } catch (e) {
- throw(e.constructor());
- }
- },
- match: "uncaught exception: Error :",
- stack: true,
+ match: "function\\\(\\\) {} :",
+ stack: undefined,
+ },
+ {
+ callback: function() {
+ try {
+ UUID("asdf");
+ } catch (e) {
+ throw (e.constructor());
+ }
},
- {
- callback: function() {
- try {
- UUID("asdf");
- } catch (e) {
- throw(e.prototype);
- }
- },
- match: "uncaught exception: undefined",
- stack: false,
+ match: "uncaught exception: Error :",
+ stack: true,
+ },
+ {
+ callback: function() {
+ try {
+ UUID("asdf");
+ } catch (e) {
+ throw (e.prototype);
+ }
},
- ];
- function recurser(depth, limit, callback) {
- if (++depth >= limit) {
- callback();
- } else {
- recurser(depth, limit, callback);
- }
- }
- function assertMatch(m, l) {
- assert(m.test(l), m + " didn't match \"" + l + "\"");
+ match: "uncaught exception: undefined",
+ stack: false,
+ },
+];
+function recurser(depth, limit, callback) {
+ if (++depth >= limit) {
+ callback();
+ } else {
+ recurser(depth, limit, callback);
}
- tests.forEach(function(t) {
- let code = tojson(recurser);
- [1, 2, 10].forEach(function(depth) {
- clearRawMongoProgramOutput();
- assert.throws(startParallelShell(
- code + ";\nrecurser(0," + depth + "," + tojson(t.callback) + ");", false, true));
- let output = rawMongoProgramOutput();
- let lines = output.split(/\s*\n/);
- let matchShellExp = false;
- while (lines.length > 0 & matchShellExp !== true) {
- let line = lines.shift();
- if (line.match(/MongoDB shell version/)) {
- matchShellExp = true;
- }
+}
+function assertMatch(m, l) {
+ assert(m.test(l), m + " didn't match \"" + l + "\"");
+}
+tests.forEach(function(t) {
+ let code = tojson(recurser);
+ [1, 2, 10].forEach(function(depth) {
+ clearRawMongoProgramOutput();
+ assert.throws(startParallelShell(
+ code + ";\nrecurser(0," + depth + "," + tojson(t.callback) + ");", false, true));
+ let output = rawMongoProgramOutput();
+ let lines = output.split(/\s*\n/);
+ let matchShellExp = false;
+ while (lines.length > 0 & matchShellExp !== true) {
+ let line = lines.shift();
+ if (line.match(/MongoDB shell version/)) {
+ matchShellExp = true;
}
- assert(matchShellExp);
- assertMatch(/^\s*$/, lines.pop());
- assertMatch(/exiting with code/, lines.pop());
- assertMatch(new RegExp("\\\[js\\\] " + t.match + "$"), lines.shift());
+ }
+ assert(matchShellExp);
+ assertMatch(/^\s*$/, lines.pop());
+ assertMatch(/exiting with code/, lines.pop());
+ assertMatch(new RegExp("\\\[js\\\] " + t.match + "$"), lines.shift());
- if (t.stack == true) {
- assert.eq(lines.length,
- depth + 2); // plus one for the shell and one for the callback
- lines.forEach(function(l) {
- assertMatch(/\@\(shell eval\):\d+:\d+/, l);
- });
- lines.pop();
- lines.shift();
- lines.forEach(function(l) {
- assertMatch(/recurser\@/, l);
- });
- } else if (t.stack == false) {
- assert.eq(lines.length, 0);
- } else if (t.stack == undefined) {
- assert.eq(lines.length, 1);
- assertMatch(/undefined/, lines.pop());
- }
- });
+ if (t.stack == true) {
+ assert.eq(lines.length,
+ depth + 2); // plus one for the shell and one for the callback
+ lines.forEach(function(l) {
+ assertMatch(/\@\(shell eval\):\d+:\d+/, l);
+ });
+ lines.pop();
+ lines.shift();
+ lines.forEach(function(l) {
+ assertMatch(/recurser\@/, l);
+ });
+ } else if (t.stack == false) {
+ assert.eq(lines.length, 0);
+ } else if (t.stack == undefined) {
+ assert.eq(lines.length, 1);
+ assertMatch(/undefined/, lines.pop());
+ }
});
+});
})();