0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

some test refactoring

This commit is contained in:
Eliot Horowitz 2009-04-23 22:44:19 -04:00
parent 7596bf2e98
commit 9c88c32b04
4 changed files with 40 additions and 11 deletions

View File

@ -92,7 +92,7 @@ int main( int argc, char** argv ) {
// NOTE Starting JNI changes global state (for example, locale and FPU precision);
// make sure all tests run with this setup, by running javajs tests first.
tests.add( javajsTests(), "javajs" );
tests.add( jsTests(), "js" );
tests.add( btreeTests(), "btree" );
tests.add( jsobjTests(), "jsobj" );

View File

@ -22,7 +22,7 @@
using namespace mongo;
UnitTest::TestPtr btreeTests();
UnitTest::TestPtr javajsTests();
UnitTest::TestPtr jsTests();
UnitTest::TestPtr jsobjTests();
UnitTest::TestPtr jsonTests();
UnitTest::TestPtr matcherTests();

View File

@ -21,7 +21,7 @@
#include "dbtests.h"
namespace JavaJSTests {
namespace JSTests {
class Fundamental {
public:
@ -35,15 +35,49 @@ namespace JavaJSTests {
}
};
class BasicScope {
public:
void run(){
Scope * s = globalScriptEngine->createScope();
s->setNumber( "x" , 5 );
assert( 5 == s->getNumber( "x" ) );
s->setNumber( "x" , 1.67 );
assert( 1.67 == s->getNumber( "x" ) );
s->setString( "s" , "eliot was here" );
assert( "eliot was here" == s->getString( "s" ) );
s->setBoolean( "b" , true );
assert( s->getBoolean( "b" ) );
if ( 0 ){
s->setBoolean( "b" , false );
assert( ! s->getBoolean( "b" ) );
}
// TODO: setObject
delete s;
}
};
// TODO:
// functions
// setThis
// init
class All : public UnitTest::Suite {
public:
All() {
add< Fundamental >();
add< BasicScope >();
}
};
} // namespace JavaJSTests
UnitTest::TestPtr javajsTests() {
return UnitTest::createSuite< JavaJSTests::All >();
UnitTest::TestPtr jsTests() {
return UnitTest::createSuite< JSTests::All >();
}

View File

@ -114,12 +114,7 @@ namespace mongo {
};
void SMEngine::runTest(){
{
SMScope scope;
ScriptingFunction func = scope.createFunction( "x = 5" );
scope.invoke( func , BSONObj() );
assert( scope.getNumber( "x" ) == 5 );
}
// this is deprecated
}
}