diff options
author | gregs <greg@10gen.com> | 2011-07-08 18:26:53 -0400 |
---|---|---|
committer | gregs <greg@10gen.com> | 2011-07-27 12:37:46 -0400 |
commit | 3d1a47381aa0222c955f49b867b4ab0008137ab5 (patch) | |
tree | 5465d9d8ca3a8cd39f8ee5db9f4d006aa51352da /shell | |
parent | 4e35995b5ea2c89e7c4ea703d310234d161f1d68 (diff) | |
download | mongo-3d1a47381aa0222c955f49b867b4ab0008137ab5.tar.gz |
add between assertion to js
Diffstat (limited to 'shell')
-rw-r--r-- | shell/utils.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/shell/utils.js b/shell/utils.js index 9a239dbc4a9..b7c9153ba30 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -211,6 +211,18 @@ assert.gte = function( a , b , msg ){ doassert( a + " is not greater than or eq " + b + " : " + msg ); } +assert.between = function( a, b, c, msg, inclusive ){ + if ( assert._debug && msg ) print( "in assert for: " + msg ); + + if( ( inclusive == undefined || inclusive = true ) && + a <= b && b <= c ) return; + else if( a < b && b < c ) return; + + doassert( b + " is not between " + a + " and " + c + " : " + msg ); +} + +assert.betweenIn = function( a, b, c, msg ){ assert.between( a, b, c, msg, true ) } +assert.betweenEx = function( a, b, c, msg ){ assert.between( a, b, c, msg, false ) } assert.close = function( a , b , msg , places ){ if (places === undefined) { |