summaryrefslogtreecommitdiff
path: root/shell/utils.js
diff options
context:
space:
mode:
authorgregs <greg@10gen.com>2011-08-04 13:44:30 -0400
committergregs <greg@10gen.com>2011-08-04 13:44:30 -0400
commitec9147aaeb0a10c0f40ab962056ba7c7dacdab8c (patch)
tree3eaf4a8f56eff13d0f8402843222884ccba43d8d /shell/utils.js
parent88094494077b407bf1cf2ce6351252ab4b0d0d60 (diff)
downloadmongo-ec9147aaeb0a10c0f40ab962056ba7c7dacdab8c.tar.gz
tests for including location in geoNear results
Diffstat (limited to 'shell/utils.js')
-rw-r--r--shell/utils.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/shell/utils.js b/shell/utils.js
index ee0dd1aefe6..a903691fbd4 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -84,6 +84,26 @@ assert.neq = function( a , b , msg ){
doassert( "[" + a + "] != [" + b + "] are equal : " + msg );
}
+assert.contains = function( o, arr, msg ){
+ var wasIn = false
+
+ if( ! arr.length ){
+ for( i in arr ){
+ wasIn = arr[i] == o || ( ( arr[i] != null && o != null ) && friendlyEqual( arr[i] , o ) )
+ return;
+ if( wasIn ) break
+ }
+ }
+ 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
+ }
+ }
+
+ if( ! wasIn ) doassert( tojson( o ) + " was not in " + tojson( arr ) + " : " + msg )
+}
+
assert.repeat = function( f, msg, timeout, interval ) {
if ( assert._debug && msg ) print( "in assert for: " + msg );