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:
parent
7596bf2e98
commit
9c88c32b04
@ -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" );
|
||||
|
@ -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();
|
||||
|
@ -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 >();
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user