summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorMike Grundy <michael.grundy@10gen.com>2016-02-19 16:46:28 -0500
committerMike Grundy <michael.grundy@10gen.com>2016-02-25 09:48:18 -0500
commit4e87684433692889660c57763fa5c188651b646d (patch)
treee3bf96cae45afc0b9ea85102b740284ea8f3150e /src/mongo/shell
parent0be10245f35e75ffd92fbe775eadc5df8309f3cf (diff)
downloadmongo-4e87684433692889660c57763fa5c188651b646d.tar.gz
SERVER-22732 assert.contains() has unreachable code after return
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/assert.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index b3b7947cf66..98e013600d8 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -127,22 +127,20 @@ assert.neq = function(a, b, msg){
assert.contains = function(o, arr, msg){
var wasIn = false;
-
- if(! arr.length){
- for(var i in arr){
- wasIn = arr[i] == o || ((arr[i] != null && o != null) && friendlyEqual(arr[i], o));
- return;
- if(wasIn) break;
- }
+ if (!Array.isArray(arr)) {
+ throw new Error("The second argument to assert.contains must be an array.");
}
- else {
- for(var i = 0; i < arr.length; i++){
- wasIn = arr[i] == o || ((arr[i] != null && o != null) && friendlyEqual(arr[i], o));
- if(wasIn) break;
+
+ for(var i = 0; i < arr.length; i++){
+ wasIn = arr[i] == o || ((arr[i] != null && o != null) && friendlyEqual(arr[i], o));
+ if(wasIn) {
+ break;
}
}
- if(! wasIn) doassert(tojson(o) + " was not in " + tojson(arr) + " : " + msg);
+ if(!wasIn) {
+ doassert(tojson(o) + " was not in " + tojson(arr) + " : " + msg);
+ }
};
assert.soon = function(f, msg, timeout /*ms*/, interval) {