diff options
author | Aaron <aaron@10gen.com> | 2010-03-01 09:26:35 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-03-01 09:26:35 -0800 |
commit | 89f3e6d65b0d0daa5e70a9dc97a60297ed167678 (patch) | |
tree | e5ec78078f679f106cb5e8595beac09cb5163b89 /dbtests | |
parent | 45d3cfbfcf6176d70f7ea4be7b136eb1213f0c4a (diff) | |
download | mongo-89f3e6d65b0d0daa5e70a9dc97a60297ed167678.tar.gz |
SERVER-677 add floatApprox sm
Diffstat (limited to 'dbtests')
-rw-r--r-- | dbtests/jstests.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp index d38081eafd9..e7077707caa 100644 --- a/dbtests/jstests.cpp +++ b/dbtests/jstests.cpp @@ -528,7 +528,7 @@ namespace JSTests { BSONObj out = s->getObject( "a" ); ASSERT_EQUALS( mongo::NumberLong, out.firstElement().type() ); - ASSERT( s->exec( "b = {b:a.a}", "foo", false, true, false ) ); + ASSERT( s->exec( "printjson( a ); b = {b:a.a}", "foo", false, true, false ) ); out = s->getObject( "b" ); ASSERT_EQUALS( mongo::NumberLong, out.firstElement().type() ); ASSERT_EQUALS( val, out.firstElement().numberLong() ); @@ -543,6 +543,26 @@ namespace JSTests { out = s->getObject( "d" ); ASSERT_EQUALS( NumberDouble, out.firstElement().type() ); ASSERT_EQUALS( double( val ), out.firstElement().number() ); + + ASSERT( s->exec( "e = {e:a.a.floatApprox}", "foo", false, true, false ) ); + out = s->getObject( "e" ); + ASSERT_EQUALS( NumberDouble, out.firstElement().type() ); + ASSERT_EQUALS( double( val ), out.firstElement().number() ); + + ASSERT( s->exec( "f = {f:a.a.top}", "foo", false, true, false ) ); + out = s->getObject( "f" ); + ASSERT_EQUALS( NumberDouble, out.firstElement().type() ); + + s->setObject( "z", BSON( "z" << (long long)( 4 ) ) ); + ASSERT( s->exec( "y = {y:z.z.top}", "foo", false, true, false ) ); + out = s->getObject( "y" ); + ASSERT_EQUALS( Undefined, out.firstElement().type() ); + + ASSERT( s->exec( "x = {x:z.z.floatApprox}", "foo", false, true, false ) ); + out = s->getObject( "x" ); + ASSERT_EQUALS( NumberDouble, out.firstElement().type() ); + ASSERT_EQUALS( double( 4 ), out.firstElement().number() ); + } }; |