diff options
author | Aaron <aaron@10gen.com> | 2009-12-15 15:52:41 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-12-15 15:52:41 -0800 |
commit | 8add9a17b9fe9d4a0a647c982326a2279aac2d23 (patch) | |
tree | 81f18e6948ba8e4f04769e7de03d60f6e46f1984 /dbtests/jstests.cpp | |
parent | a6e2b4a60513eb4f11084475053818228c0ce9a3 (diff) | |
download | mongo-8add9a17b9fe9d4a0a647c982326a2279aac2d23.tar.gz |
SERVER-446 implement readOnly mode in v8 engine
Diffstat (limited to 'dbtests/jstests.cpp')
-rw-r--r-- | dbtests/jstests.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp index e18074672dd..b5b2d68e650 100644 --- a/dbtests/jstests.cpp +++ b/dbtests/jstests.cpp @@ -255,9 +255,13 @@ namespace JSTests { BSONObj o = BSON( "x" << 17 << "y" << "eliot" << "z" << "sara" << "zz" << BSONObj() ); s->setObject( "blah" , o , true ); - - s->invoke( "blah.a = 19;" , BSONObj() ); + + s->invoke( "blah.y = 'e'", BSONObj() ); BSONObj out = s->getObject( "blah" ); + ASSERT( strlen( out["y"].valuestr() ) > 1 ); + + s->invoke( "blah.a = 19;" , BSONObj() ); + out = s->getObject( "blah" ); ASSERT( out["a"].eoo() ); s->invoke( "blah.zz.a = 19;" , BSONObj() ); @@ -267,7 +271,26 @@ namespace JSTests { s->setObject( "blah.zz", BSON( "a" << 19 ) ); out = s->getObject( "blah" ); ASSERT( out["zz"].embeddedObject()["a"].eoo() ); - + + s->invoke( "delete blah['x']" , BSONObj() ); + out = s->getObject( "blah" ); + ASSERT( !out["x"].eoo() ); + + // read-only object itself can be overwritten + s->invoke( "blah = {}", BSONObj() ); + out = s->getObject( "blah" ); + ASSERT( out.isEmpty() ); + + // test array + o = fromjson( "{a:[1,2,3]}" ); + s->setObject( "blah", o, true ); + out = s->getObject( "blah" ); + s->invoke( "blah.a[ 0 ] = 4;", BSONObj() ); + s->invoke( "delete blah['a'][ 2 ];", BSONObj() ); + out = s->getObject( "blah" ); + ASSERT_EQUALS( 1.0, out[ "a" ].embeddedObject()[ 0 ].number() ); + ASSERT_EQUALS( 3.0, out[ "a" ].embeddedObject()[ 2 ].number() ); + delete s; } }; |