summaryrefslogtreecommitdiff
path: root/dbtests/jstests.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-12-15 11:22:19 -0800
committerAaron <aaron@10gen.com>2009-12-15 11:22:19 -0800
commita6e2b4a60513eb4f11084475053818228c0ce9a3 (patch)
tree88b7295d3e1a3b6f55f4598383afc5dc276625c2 /dbtests/jstests.cpp
parent043ad72b74b84b3e57360524e7d7a2133040b80c (diff)
downloadmongo-a6e2b4a60513eb4f11084475053818228c0ce9a3.tar.gz
MINOR enhanced read only js tests
Diffstat (limited to 'dbtests/jstests.cpp')
-rw-r--r--dbtests/jstests.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp
index 4729f0a9436..e18074672dd 100644
--- a/dbtests/jstests.cpp
+++ b/dbtests/jstests.cpp
@@ -227,18 +227,47 @@ namespace JSTests {
}
};
- class ObjectModTests {
+ class SetImplicit {
+ public:
+ void run() {
+ Scope *s = globalScriptEngine->createScope();
+
+ BSONObj o = BSON( "foo" << "bar" );
+ s->setObject( "a.b", o );
+ ASSERT( s->getObject( "a" ).isEmpty() );
+
+ BSONObj o2 = BSONObj();
+ s->setObject( "a", o2 );
+ s->setObject( "a.b", o );
+ ASSERT( s->getObject( "a" ).isEmpty() );
+
+ o2 = fromjson( "{b:{}}" );
+ s->setObject( "a", o2 );
+ s->setObject( "a.b", o );
+ ASSERT( !s->getObject( "a" ).isEmpty() );
+ }
+ };
+
+ class ObjectModReadonlyTests {
public:
void run(){
Scope * s = globalScriptEngine->createScope();
- BSONObj o = BSON( "x" << 17 << "y" << "eliot" << "z" << "sara" );
+ BSONObj o = BSON( "x" << 17 << "y" << "eliot" << "z" << "sara" << "zz" << BSONObj() );
s->setObject( "blah" , o , true );
s->invoke( "blah.a = 19;" , BSONObj() );
BSONObj out = s->getObject( "blah" );
ASSERT( out["a"].eoo() );
+ s->invoke( "blah.zz.a = 19;" , BSONObj() );
+ out = s->getObject( "blah" );
+ ASSERT( out["zz"].embeddedObject()["a"].eoo() );
+
+ s->setObject( "blah.zz", BSON( "a" << 19 ) );
+ out = s->getObject( "blah" );
+ ASSERT( out["zz"].embeddedObject()["a"].eoo() );
+
delete s;
}
};
@@ -632,7 +661,8 @@ namespace JSTests {
add< ObjectMapping >();
add< ObjectDecoding >();
add< JSOIDTests >();
- add< ObjectModTests >();
+ add< SetImplicit >();
+ add< ObjectModReadonlyTests >();
add< OtherJSTypes >();
add< SpecialDBTypes >();
add< TypeConservation >();