MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
testShell.cpp File Reference
#include "header.h"
#include "Shell.h"
#include "../scheduling/Clock.h"
#include "../scheduling/testScheduling.h"
#include "../builtins/Arith.h"
#include "SparseMatrix.h"
#include "SparseMsg.h"
#include "SingleMsg.h"
#include "OneToAllMsg.h"
#include "Wildcard.h"
+ Include dependency graph for testShell.cpp:

Go to the source code of this file.

Functions

bool checkArg1 (Id id, double v0, double v1, double v2, double v3, double v4)
 
bool checkOutput (Id e, double v0, double v1, double v2, double v3, double v4)
 
bool extractIndex (const string &s, unsigned int &index)
 
void filterOffNodeTargets (unsigned int start, unsigned int end, bool isSrcGlobal, unsigned int myNode, vector< vector< Eref > > &erefs, vector< vector< bool > > &targetNodes)
 
void testChildren ()
 Test the Neutral::children and buildTree. More...
 
void testChopPath ()
 
void testChopString ()
 
void testCopy ()
 
void testCopyFieldElement ()
 
void testCopyMsgOps ()
 
void testDescendant ()
 Test the Neutral::isDescendant. More...
 
void testExtractIndices ()
 
void testFilterOffNodeTargets ()
 
void testFindModelParent ()
 
void testGetMsgs ()
 
void testGetMsgSrcAndTarget ()
 
void testInterNodeOps ()
 
void testMove ()
 
void testMpiShell ()
 
void testObjIdToAndFromPath ()
 
void testShell ()
 
void testShellAddMsg ()
 
void testShellParserCreateDelete ()
 
void testShellParserQuit ()
 
void testShellParserStart ()
 
void testShellSetGet ()
 
void testSyncSynapseSize ()
 
void testTreeTraversal ()
 
void testWildcard ()
 
void verifyKids (Id f1, Id f2a, Id f2b, Id f3, Id f4a, Id f4b)
 Utility function to check a commonly used tree structure. More...
 

Variables

const bool TEST_WARNING = false
 

Function Documentation

bool checkArg1 ( Id  id,
double  v0,
double  v1,
double  v2,
double  v3,
double  v4 
)

Definition at line 762 of file testShell.cpp.

References Eref::data().

764 {
765  bool ret = 1;
766  bool report = 0;
767  Eref e0( id.element(), 0 );
768  double val = reinterpret_cast< Arith* >( e0.data() )->getArg1();
769  ret = ret && ( fabs( val - v0 ) < 1e-6 );
770  if (report) cout << "( " << v0 << ", " << val << " ) ";
771 
772  Eref e1( id.element(), 1 );
773  val = reinterpret_cast< Arith* >( e1.data() )->getArg1();
774  ret = ret && ( fabs( val - v1 ) < 1e-6 );
775  if (report) cout << "( " << v1 << ", " << val << " ) ";
776 
777  Eref e2( id.element(), 2 );
778  val = reinterpret_cast< Arith* >( e2.data() )->getArg1();
779  ret = ret && ( fabs( val - v2 ) < 1e-6 );
780  if (report) cout << "( " << v2 << ", " << val << " ) ";
781 
782  Eref e3( id.element(), 3 );
783  val = reinterpret_cast< Arith* >( e3.data() )->getArg1();
784  ret = ret && ( fabs( val - v3 ) < 1e-6 );
785  if (report) cout << "( " << v3 << ", " << val << " ) ";
786 
787  Eref e4( id.element(), 4 );
788  val = reinterpret_cast< Arith* >( e4.data() )->getArg1();
789  ret = ret && ( fabs( val - v4 ) < 1e-6 );
790  if (report) cout << "( " << v4 << ", " << val << " )\n";
791 
792  return ret;
793 }
Definition: Arith.h:12
Definition: Eref.h:26

+ Here is the call graph for this function:

bool checkOutput ( Id  e,
double  v0,
double  v1,
double  v2,
double  v3,
double  v4 
)

Definition at line 795 of file testShell.cpp.

References doubleEq(), and Field< A >::get().

Referenced by testCopyMsgOps(), and testShellAddMsg().

797 {
798  bool ret = true;
799  bool report = 0;
800 
801  vector< double > correct;
802  correct.push_back( v0 );
803  correct.push_back( v1 );
804  correct.push_back( v2 );
805  correct.push_back( v3 );
806  correct.push_back( v4 );
807 
808  vector< double > actual(5);
809  for ( unsigned int i = 0; i < 5; ++i ) {
810  actual[i] = Field< double >::get( ObjId( e, i ), "outputValue" );
811  ret = ret && doubleEq( actual[i], correct[i] );
812  }
813  if (report || !ret ) {
814  cout << endl;
815  for ( unsigned int i = 0; i < 5; ++i )
816  cout << "(" << correct[i] << ", " << actual[i] << ") ";
817  }
818  /*
819  vector< double > retVec;
820  Field< double >::getVec( e, "outputValue", retVec );
821  assert( retVec.size() == 5 );
822 
823  for ( unsigned int i = 0; i < 5; ++i ) {
824  ret = ret & doubleEq( retVec[i], correct[i] );
825  if (report) cout << "( " << correct[i] << ", " << retVec[i] << " ) ";
826  }
827  if ( !ret ) {
828  for ( unsigned int i = 0; i < 5; ++i ) {
829  cout << "( " << correct[i] << ", " << retVec[i] << " ) ";
830  }
831  }
832  */
833  return ret;
834 }
Definition: ObjId.h:20
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool extractIndex ( const string &  s,
unsigned int &  index 
)

Definition at line 423 of file Shell.cpp.

Referenced by Shell::chopPath(), and testExtractIndices().

424 {
425  vector< unsigned int > open;
426  vector< unsigned int > close;
427 
428  index = 0;
429  if ( s.length() == 0 ) // a plain slash is OK
430  return true;
431 
432  if ( s[0] == '[' ) // Cannot open with a brace
433  return false;
434 
435  for ( unsigned int i = 0; i < s.length(); ++i )
436  {
437  if ( s[i] == '[' )
438  open.push_back( i+1 );
439  else if ( s[i] == ']' )
440  close.push_back( i );
441  }
442 
443  if ( open.size() != close.size() )
444  return false;
445  if ( open.size() == 0 )
446  return true; // the index was set already to zero.
447  int j = atoi( s.c_str() + open[0] );
448  if ( j >= 0 )
449  {
450  index = j;
451  return true;
452  }
453  return false;
454 }

+ Here is the caller graph for this function:

void filterOffNodeTargets ( unsigned int  start,
unsigned int  end,
bool  isSrcGlobal,
unsigned int  myNode,
vector< vector< Eref > > &  erefs,
vector< vector< bool > > &  targetNodes 
)

Picks which messages we retain in the MsgDigest. Does so at two levels:

  • Builds an array[][] of bools to indicate messages sourced here that go off-node. These will have special HopFuncs added.
  • Retains entries in erefs that are sourced anywhere, but targetted here. Need to be able to handle off-node messages landing here, as well as the entirely local messages.

Definition at line 429 of file Element.cpp.

References ALLDATA, Eref::dataIndex(), Eref::element(), Eref::getNode(), Element::isGlobal(), and Shell::numNodes().

Referenced by Element::putTargetsInDigest(), and testFilterOffNodeTargets().

436 {
437  // i is index of src dataid
438  for ( unsigned int i = 0; i < erefs.size(); ++i )
439  {
440  vector< Eref > temp;
441  vector< Eref >& vec = erefs[i];
442  for ( unsigned int j = 0; j < vec.size(); ++j ) // list of tgts.
443  {
444  const Eref& er = vec[j];
445  unsigned int node = er.getNode();
446  if ( !isSrcGlobal && // Don't send any msgs
447  // off-node, as it will be dealt with by the off-node src.
448  i >= start && i < end ) // Sourced from current node.
449  {
450  if ( node != myNode ) // Target is off-node
451  targetNodes[i][node] = true;
452  if ( er.dataIndex() == ALLDATA || er.element()->isGlobal())
453  {
454  for ( unsigned int k = 0; k < Shell::numNodes(); ++k )
455  if ( k != myNode )
456  targetNodes[i][k] = true;
457  }
458  }
459  if ( node == myNode ) // Regardless of source, target is onNode.
460  temp.push_back( er );
461  }
462  erefs[i] = temp; // Swap out the original set with the new one.
463  }
464 }
unsigned int getNode() const
Definition: Eref.cpp:52
unsigned int dataIndex() const
Definition: Eref.h:50
Element * element() const
Definition: Eref.h:42
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
static unsigned int myNode
Definition: Eref.h:26
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
static unsigned int numNodes()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testChildren ( )

Test the Neutral::children and buildTree.

Definition at line 290 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::eref(), Field< A >::set(), TEST_WARNING, and verifyKids().

Referenced by testMpiShell(), and testShell().

291 {
292  Eref sheller = Id().eref();
293  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
294 
295  Id f1 = shell->doCreate( "Neutral", Id(), "f1", 1 );
296  Id f2a = shell->doCreate( "Neutral", f1, "f2a", 1 );
297  Id f2b = shell->doCreate( "Neutral", f1, "f2b", 1 );
298  Id f3 = shell->doCreate( "Neutral", f2a, "f3", 1 );
299  Id f4a = shell->doCreate( "Neutral", f3, "f4a", 1 );
300  Id f4b = shell->doCreate( "Neutral", f3, "f4b", 1 );
301 
302  verifyKids( f1, f2a, f2b, f3, f4a, f4b );
303 
304  if ( TEST_WARNING ) {
305  // Should fail.
306  cout << "\nTesting warning for creating element with existing name: ";
307  Id fx1 = shell->doCreate( "Neutral", f1, "f2b", 1 );
308  assert( fx1 == Id() );
309  }
310 
311  // Should succeed
312  Field< string >::set( f4a, "name", "hippo" );
313  if ( TEST_WARNING ) {
314  // Should fail, because same name already exists.
315  cout << "\nTesting warning for name change to existing name: ";
316  Field< string >::set( f4a, "name", "f4b" );
317  }
318 
319  shell->doDelete( f1 );
320  cout << "." << flush;
321 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
void verifyKids(Id f1, Id f2a, Id f2b, Id f3, Id f4a, Id f4b)
Utility function to check a commonly used tree structure.
Definition: testShell.cpp:266
Definition: Eref.h:26
const bool TEST_WARNING
Definition: testShell.cpp:25
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testChopPath ( )

Definition at line 1345 of file testShell.cpp.

References Shell::chopPath().

Referenced by testShell().

1346 {
1347  vector< string > args;
1348  vector< unsigned int > index;
1349 
1350  assert( Shell::chopPath( "foo[1]/bar[2]/zod[3]", args, index ) == 0 );
1351  assert( args.size() == 3 );
1352  assert( args[0] == "foo" );
1353  assert( args[1] == "bar" );
1354  assert( args[2] == "zod" );
1355 
1356  assert( index.size() == 3 );
1357 
1358  assert( index[0] == 1 );
1359  assert( index[1] == 2 );
1360  assert( index[2] == 3 );
1361 
1362  assert( Shell::chopPath( "/foo/bar[1]/zod[2]/zung[3]",
1363  args, index ) == 1 );
1364  assert( args.size() == 4 );
1365  assert( args[0] == "foo" );
1366  assert( args[1] == "bar" );
1367  assert( args[2] == "zod" );
1368  assert( args[3] == "zung" );
1369 
1370  assert( index.size() == 4 );
1371 
1372  assert( index[0] == 0 );
1373  assert( index[1] == 1 );
1374  assert( index[2] == 2 );
1375  assert( index[3] == 3 );
1376 
1377  cout << "." << flush;
1378 }
static bool chopPath(const string &path, vector< string > &ret, vector< unsigned int > &index)
Definition: Shell.cpp:512

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testChopString ( )

Definition at line 1296 of file testShell.cpp.

References Shell::chopString().

1297 {
1298  vector< string > args;
1299 
1300  assert( Shell::chopString( ".", args ) == 0 );
1301  assert( args.size() == 1 );
1302  assert( args[0] == "." );
1303 
1304  assert( Shell::chopString( "/", args ) == 1 );
1305  assert( args.size() == 0 );
1306 
1307  assert( Shell::chopString( "..", args ) == 0 );
1308  assert( args.size() == 1 );
1309  assert( args[0] == ".." );
1310 
1311  assert( Shell::chopString( "./", args ) == 0 );
1312  assert( args.size() == 1 );
1313  assert( args[0] == "." );
1314 
1315  assert( Shell::chopString( "./foo", args ) == 0 );
1316  assert( args.size() == 2 );
1317  assert( args[0] == "." );
1318  assert( args[1] == "foo" );
1319 
1320  assert( Shell::chopString( "/foo", args ) == 1 );
1321  assert( args.size() == 1 );
1322  assert( args[0] == "foo" );
1323 
1324  assert( Shell::chopString( "foo", args ) == 0 );
1325  assert( args.size() == 1 );
1326  assert( args[0] == "foo" );
1327 
1328  assert( Shell::chopString( "foo/", args ) == 0 );
1329  assert( args.size() == 1 );
1330  assert( args[0] == "foo" );
1331 
1332  assert( Shell::chopString( "/foo/", args ) == 1 );
1333  assert( args.size() == 1 );
1334  assert( args[0] == "foo" );
1335 
1336  assert( Shell::chopString( "foo/bar/zod", args ) == 0 );
1337  assert( args.size() == 3 );
1338  assert( args[0] == "foo" );
1339  assert( args[1] == "bar" );
1340  assert( args[2] == "zod" );
1341 
1342  cout << "." << flush;
1343 }
static bool chopString(const string &path, vector< string > &ret, char separator= '/')
Definition: Shell.cpp:459

+ Here is the call graph for this function:

void testCopy ( )

Definition at line 388 of file testShell.cpp.

References Eref::data(), Shell::doCopy(), Shell::doCreate(), Shell::doDelete(), Id::element(), Id::eref(), Field< A >::get(), Neutral::getChildren(), Element::getName(), Neutral::getParent(), MooseGlobal, path, and verifyKids().

Referenced by testMpiShell().

389 {
390  Eref sheller = Id().eref();
391  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
392 
393  Id f1 = shell->doCreate( "Neutral", Id(), "f1", 1, MooseGlobal );
394  Id f2a = shell->doCreate( "Neutral", f1, "f2a", 1, MooseGlobal );
395  Id f2b = shell->doCreate( "Neutral", f1, "f2b", 1, MooseGlobal );
396  Id f3 = shell->doCreate( "Neutral", f2a, "f3", 1, MooseGlobal );
397  Id f4a = shell->doCreate( "Neutral", f3, "f4a", 1, MooseGlobal );
398  Id f4b = shell->doCreate( "Neutral", f3, "f4b", 1, MooseGlobal );
399 
400  verifyKids( f1, f2a, f2b, f3, f4a, f4b );
401 
402  ObjId pa = Field< ObjId >::get( f3, "parent" );
403  assert( pa == ObjId( f2a, 0 ) );
404  pa = Field< ObjId >::get( f2a, "parent" );
405  assert( pa == ObjId( f1, 0 ) );
406  string path = Field< string >::get( f3, "path" );
407  assert( path == "/f1[0]/f2a[0]/f3[0]" );
408 
410  Id dupf2a = shell->doCopy( f2a, Id(), "TheElephantsAreLoose", 1, false, false );
412 
413  verifyKids( f1, f2a, f2b, f3, f4a, f4b );
414 
415  assert( dupf2a != Id() );
416  // pa = Field< ObjId >::get( dupf2a, "parent" );
417  // assert( pa == ObjId( f1, 0 ) );
418  assert( dupf2a.element()->getName() == "TheElephantsAreLoose" );
419  Neutral* f2aDupData = reinterpret_cast< Neutral* >( dupf2a.eref().data() );
420  Id dupf3 = f2aDupData->child( dupf2a.eref(), "f3" );
421  assert( dupf3 != Id() );
422  assert( dupf3 != f3 );
423  assert( dupf3.element()->getName() == "f3" );
424  vector< Id > kids = f2aDupData->getChildren( dupf2a.eref() );
425  assert( kids.size() == 1 );
426  assert( kids[0] == dupf3 );
427 
428  Neutral* f3DupData = reinterpret_cast< Neutral* >( dupf3.eref().data());
429  assert( f3DupData->getParent( dupf3.eref() ) == ObjId( dupf2a, 0 ));
430  kids = f3DupData->getChildren( dupf3.eref() );
431  assert( kids.size() == 2 );
432  assert( kids[0].element()->getName() == "f4a" );
433  assert( kids[1].element()->getName() == "f4b" );
434 
435  shell->doDelete( f1 );
436  shell->doDelete( dupf2a );
437  cout << "." << flush;
438 }
char * data() const
Definition: Eref.cpp:41
ObjId getParent(const Eref &e) const
Definition: Neutral.cpp:326
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
Id doCopy(Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Returns the Id of the root of the copied tree upon success.
Definition: ShellCopy.cpp:16
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
vector< Id > getChildren(const Eref &e) const
Definition: Neutral.cpp:334
void verifyKids(Id f1, Id f2a, Id f2b, Id f3, Id f4a, Id f4b)
Utility function to check a commonly used tree structure.
Definition: testShell.cpp:266
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
const string & getName() const
Definition: Element.cpp:56
static char path[]
Definition: mfield.cpp:403
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCopyFieldElement ( )

Definition at line 440 of file testShell.cpp.

References Neutral::children(), Eref::data(), Shell::doCopy(), Shell::doCreate(), Shell::doDelete(), doubleEq(), Id::element(), Id::eref(), Field< A >::get(), Element::getName(), Field< A >::getVec(), Element::isGlobal(), MooseGlobal, Element::numData(), Element::numField(), Field< A >::set(), Field< A >::setRepeat(), Field< A >::setVec(), and Id::value().

Referenced by testMpiShell().

441 {
442  Eref sheller = Id().eref();
443  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
444  unsigned int size = 10;
445  unsigned int size2 = 17;
446  Id origId = shell->doCreate( "SimpleSynHandler", Id(), "f1", size, MooseGlobal );
447  Id origSynId( origId.value() + 1 );
448  Id origChild = shell->doCreate( "Neutral", origId, "f2", size2, MooseGlobal );
449 
450  Element* syn = origSynId.element();
451  assert( syn != 0 );
452  assert( syn->getName() == "synapse" );
453  assert( syn->numData() == size );
454  assert( origChild.element()->numData() == size2 );
455  assert( syn->numField( 0 ) == 0 );
456  assert( syn->isGlobal() );
457  vector< unsigned int > vec(size);
458  /*
459  for ( unsigned int i = 0; i < size; ++i )
460  vec[i] = i;
461  bool ret = Field< unsigned int >::setVec( origId, "numSynapse", vec );
462  assert( ret );
463  */
464  bool ret;
465  for ( unsigned int i = 0; i < size; ++i ) {
466  ret = Field< unsigned int >::set( ObjId( origId, i ),
467  "numSynapse", i );
468  assert( ret );
469  }
470 
471  for ( unsigned int i = 0; i < size; ++i ) {
472  vector< double > delay;
473  for ( unsigned int j = 0; j < i; ++j ) {
474  delay.push_back( 3.14 * j + i * i );
475  }
476  ret = Field< double >::
477  setVec( ObjId( origSynId, i ), "delay", delay );
478  assert( ret == ( i > 0 ) );
479  ret = Field< double >::
480  setRepeat( ObjId( origSynId, i ), "weight", i + 100 );
481  assert( ret );
482  }
483 
484  Eref origEr( origId.element(), 0 );
485  vector< Id > origChildren;
486  Neutral::children( origEr, origChildren );
487  assert( origChildren.size() == 2 );
488 
489  unsigned int numCopy = 2;
491  Id copyId = shell->doCopy( origId, Id(), "dup", numCopy, false, false);
493 
494  assert( copyId.element()->numData() == numCopy * size );
495  origChildren.resize( 0 );
496  Eref copyEr( copyId.element(), 0 );
497  vector< Id > copyChildren;
498  Neutral::children( origEr, origChildren );
499  Neutral::children( copyEr, copyChildren );
500  assert( origChildren.size() == 2 );
501  assert( origChildren[0] == origSynId );
502  assert( origChildren.size() == copyChildren.size() );
503  Id copySynId = copyChildren[0];
504  Id copyChild = copyChildren[1];
505 
506  Element* copySynElm = copySynId.element();
507 
508  // Element should exist even if data doesn't
509  assert ( copySynElm != 0 );
510  assert ( copySynElm->getName() == "synapse" );
511  assert( copySynElm->numData() == numCopy * size );
512  unsigned int numSyn = 0;
513  for ( unsigned int i = 0; i < numCopy * size; ++i ) {
514  // assert( copySynElm->numField( i ) == i % size );
515  unsigned int nf = Field< unsigned int >::get(
516  ObjId( copySynId, i ), "numField" );
517  assert( nf == i % size );
518  numSyn += i % size;
519  }
520 
521  assert ( copyChild.element() != 0 );
522  assert ( copyChild.element()->getName() == "f2" );
523  assert( copyChild.element()->numData() == numCopy * size2 );
524 
525  for ( unsigned int i = 0; i < numCopy * size; ++i ) {
526  unsigned int k = i % size;
527  vector< double > delay;
528  vector< double > delay2;
529  /*
530  if ( k > 0 ) {
531  double x = Field< double >::get( ObjId( copySynId, i, 0 ), "delay" );
532  cout << endl << i << ": x = " << x << endl;
533  }
534  */
535  Field< double >::getVec( ObjId( origSynId, k ), "delay", delay );
536  Field< double >::getVec( ObjId( copySynId, i ), "delay", delay2 );
537  assert( delay.size() == k );
538  assert( delay == delay2 );
539  for ( unsigned int j = 0; j < k; ++j ) {
540  assert( doubleEq( delay[j], 3.14 * j + k * k ) );
541  }
542  }
543 
544  shell->doDelete( origId );
545  shell->doDelete( copyId );
546  cout << "." << flush;
547 }
char * data() const
Definition: Eref.cpp:41
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
unsigned int value() const
Definition: Id.cpp:197
static bool setRepeat(ObjId destId, const string &field, A arg)
Definition: SetGet.h:260
Id doCopy(Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Returns the Id of the root of the copied tree upon success.
Definition: ShellCopy.cpp:16
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static void children(const Eref &e, vector< Id > &ret)
Definition: Neutral.cpp:342
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
Definition: SetGet.h:252
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static void getVec(ObjId dest, const string &field, vector< A > &vec)
Definition: SetGet.h:317
const string & getName() const
Definition: Element.cpp:56
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCopyMsgOps ( )

Definition at line 1083 of file testShell.cpp.

References checkOutput(), Eref::data(), Shell::doAddMsg(), Shell::doCopy(), Shell::doCreate(), Shell::doDelete(), Shell::doReinit(), Shell::doSetClock(), Shell::doStart(), doubleEq(), Shell::doUseClock(), Id::eref(), Field< A >::get(), init(), MooseGlobal, SetGet3< A1, A2, A3 >::set(), and SetGet1< A >::setVec().

Referenced by testMpiShell().

1084 {
1085  Eref sheller = Id().eref();
1086  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
1087  Id pa = shell->doCreate( "Neutral", Id(), "pa", 1, MooseGlobal );
1088  unsigned int size = 5;
1089 
1090 
1092  // Set up the objects.
1094  Id a1 = shell->doCreate( "Arith", pa, "a1", size, MooseGlobal );
1095  Id a2 = shell->doCreate( "Arith", pa, "a2", size, MooseGlobal );
1096 
1097  Id b1 = shell->doCreate( "Arith", pa, "b1", size, MooseGlobal );
1098  Id b2 = shell->doCreate( "Arith", pa, "b2", size, MooseGlobal );
1099 
1100  Id c1 = shell->doCreate( "Arith", pa, "c1", size, MooseGlobal );
1101  Id c2 = shell->doCreate( "Arith", pa, "c2", size, MooseGlobal );
1102 
1103  Id d1 = shell->doCreate( "Arith", pa, "d1", size, MooseGlobal );
1104  Id d2 = shell->doCreate( "Arith", pa, "d2", size, MooseGlobal );
1105 
1106  Id e1 = shell->doCreate( "Arith", pa, "e1", size, MooseGlobal );
1107  Id e2 = shell->doCreate( "Arith", pa, "e2", size, MooseGlobal );
1108 
1110  // Set up initial conditions and some scheduling.
1112  shell->doSetClock( 0, 1.0 );
1113  shell->doReinit();
1114  bool ret = 0;
1115  vector< double > init; // 12345
1116  for ( unsigned int i = 1; i < 6; ++i )
1117  init.push_back( i );
1118  ret = SetGet1< double >::setVec( a1, "arg1", init ); // 12345
1119  assert( ret );
1120  ret = SetGet1< double >::setVec( b1, "arg1", init ); // 12345
1121  assert( ret );
1122  ret = SetGet1< double >::setVec( c1, "arg1", init ); // 12345
1123  assert( ret );
1124  ret = SetGet1< double >::setVec( d1, "arg1", init ); // 12345
1125  assert( ret );
1126  ret = SetGet1< double >::setVec( e1, "arg1", init ); // 12345
1127  assert( ret );
1128 
1129 
1131  // Set up messaging
1133  // Should give 04000
1134  ObjId m1 = shell->doAddMsg( "Single",
1135  ObjId( a1, 3 ), "output", ObjId( a2, 1 ), "arg1" );
1136  assert( m1 != ObjId() );
1137 
1138  // Should give 33333
1139  ObjId m2 = shell->doAddMsg( "OneToAll",
1140  ObjId( b1, 2 ), "output", ObjId( b2, 0 ), "arg1" );
1141  assert( m2 != ObjId() );
1142 
1143  // Should give 12345
1144  ObjId m3 = shell->doAddMsg( "OneToOne",
1145  ObjId( c1, 0 ), "output", ObjId( c2, 0 ), "arg1" );
1146  assert( m3 != ObjId() );
1147 
1148  // Should give 01234
1149  ObjId m4 = shell->doAddMsg( "Diagonal",
1150  ObjId( d1, 0 ), "output", ObjId( d2, 0 ), "arg1" );
1151  assert( m4 != ObjId() );
1152 
1153  // Should give 54321
1154  ObjId m5 = shell->doAddMsg( "Sparse",
1155  ObjId( e1, 0 ), "output", ObjId( e2, 0 ), "arg1" );
1156  assert( m5 != ObjId() );
1157 
1159  m5, "setEntry", 0, 4, 0 );
1160  assert( ret );
1162  m5, "setEntry", 1, 3, 0 );
1163  assert( ret );
1165  m5, "setEntry", 2, 2, 0 );
1166  assert( ret );
1168  m5, "setEntry", 3, 1, 0 );
1169  assert( ret );
1171  m5, "setEntry", 4, 0, 0 );
1172  assert( ret );
1173 
1174  assert( ret );
1175 
1176  // ObjId clock( Id( 1 ), 0 );
1177 
1179  // Copy it
1181 
1182  Id pa2 = shell->doCopy( pa, Id(), "pa2", 1, false, false );
1183 
1185  // Pull out the child Ids.
1187  vector< Id > kids = Field< vector< Id > >::get( pa2, "children");
1188  assert ( kids.size() == 10 );
1189  shell->doUseClock( "/pa2/#", "process", 0 );
1190 
1191  unsigned int j = 0;
1192  assert( kids[j].element()->getName() == "a1" ); ++j;
1193  assert( kids[j].element()->getName() == "a2" ); ++j;
1194  assert( kids[j].element()->getName() == "b1" ); ++j;
1195  assert( kids[j].element()->getName() == "b2" ); ++j;
1196  assert( kids[j].element()->getName() == "c1" ); ++j;
1197  assert( kids[j].element()->getName() == "c2" ); ++j;
1198  assert( kids[j].element()->getName() == "d1" ); ++j;
1199  assert( kids[j].element()->getName() == "d2" ); ++j;
1200  assert( kids[j].element()->getName() == "e1" ); ++j;
1201  assert( kids[j].element()->getName() == "e2" ); ++j;
1202 
1203  /*
1204  vector< double > retVec;
1205  Field< double >::getVec( kids[0], "arg1Value", retVec );
1206  assert( retVec.size() == 5 );
1207  assert( doubleEq( retVec[i], init[i] ) );
1208  */
1209  for (unsigned int i = 0; i < 5; ++i ) {
1210  double x = Field< double >::get( ObjId( kids[0], i ), "arg1Value");
1211  assert( doubleEq( x, init[i] ) );
1212  }
1213 
1215  // Run it
1217 
1218  shell->doStart( 2 );
1219 
1221  // Check output.
1223 
1224  ret = checkOutput( kids[1], 0, 4, 0, 0, 0 );
1225  assert( ret );
1226  ret = checkOutput( kids[2], 1, 2, 3, 4, 5 );
1227  assert( ret );
1228  ret = checkOutput( kids[3], 3, 3, 3, 3, 3 );
1229  assert( ret );
1230  ret = checkOutput( kids[5], 1, 2, 3, 4, 5 );
1231  assert( ret );
1232  ret = checkOutput( kids[7], 0, 1, 2, 3, 4 );
1233  assert( ret );
1234  ret = checkOutput( kids[9], 5, 4, 3, 2, 1 );
1235  assert( ret );
1236 
1238  // Clean up.
1240  shell->doDelete( pa );
1241  shell->doDelete( pa2 );
1242 
1243  cout << "." << flush;
1244 }
Id init(int argc, char **argv, bool &doUnitTests, bool &doRegressionTests, unsigned int &benchmark)
Definition: main.cpp:150
void doStart(double runtime, bool notify=false)
Definition: Shell.cpp:332
char * data() const
Definition: Eref.cpp:41
bool checkOutput(Id e, double v0, double v1, double v2, double v3, double v4)
Definition: testShell.cpp:795
void doSetClock(unsigned int tickNum, double dt)
Definition: Shell.cpp:377
Definition: SetGet.h:236
Id doCopy(Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Returns the Id of the root of the copied tree upon success.
Definition: ShellCopy.cpp:16
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
Definition: Eref.h:26
void doReinit()
Definition: Shell.cpp:362
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
Definition: Shell.cpp:269
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3)
Definition: SetGet.h:626
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
void doUseClock(string path, string field, unsigned int tick)
Definition: Shell.cpp:382
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
Definition: SetGet.h:188
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testDescendant ( )

Test the Neutral::isDescendant.

Definition at line 234 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::eref(), and Neutral::isDescendant().

Referenced by testMpiShell().

235 {
236  Eref sheller = Id().eref();
237  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
238 
239  Id f1 = shell->doCreate( "Neutral", Id(), "f1", 1 );
240  Id f2a = shell->doCreate( "Neutral", f1, "f2a", 1 );
241  Id f2b = shell->doCreate( "Neutral", f1, "f2b", 1 );
242  Id f3aa = shell->doCreate( "Neutral", f2a, "f3aa", 1 );
243 
244  assert( Neutral::isDescendant( f3aa, Id() ) );
245  assert( Neutral::isDescendant( f3aa, f1 ) );
246  assert( Neutral::isDescendant( f3aa, f2a ) );
247  assert( Neutral::isDescendant( f3aa, f3aa ) );
248  assert( !Neutral::isDescendant( f3aa, f2b ) );
249 
250  assert( Neutral::isDescendant( f2b, Id() ) );
251  assert( Neutral::isDescendant( f2b, f2b ) );
252  assert( !Neutral::isDescendant( f2b, f2a ) );
253  assert( !Neutral::isDescendant( f2b, f3aa ) );
254 
255  assert( Neutral::isDescendant( f1, Id() ) );
256  assert( Neutral::isDescendant( f1, f1 ) );
257  assert( !Neutral::isDescendant( f1, f2a ) );
258  assert( !Neutral::isDescendant( f1, f2b ) );
259  assert( !Neutral::isDescendant( f1, f3aa ) );
260 
261  shell->doDelete( f1 );
262  cout << "." << flush;
263 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
static bool isDescendant(Id me, Id ancestor)
Definition: Neutral.cpp:647
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testExtractIndices ( )

Definition at line 1257 of file testShell.cpp.

References extractIndex().

Referenced by testShell().

1258 {
1259  unsigned int ret;
1260 
1261  bool ok = extractIndex( "foo", ret );
1262  assert( ok );
1263  assert( ret == 0 );
1264 
1265  ok = extractIndex( "..", ret );
1266  assert( ok );
1267  assert( ret == 0 );
1268 
1269  ok = extractIndex( "a1[2]", ret );
1270  assert( ok );
1271  assert( ret == 2 );
1272 
1273  ok = extractIndex( "be451[0]", ret );
1274  assert( ok );
1275  assert( ret == 0 );
1276 
1277  ok = extractIndex( "be[0", ret );
1278  assert( !ok );
1279  assert( ret == 0 );
1280 
1281  ok = extractIndex( "[0]be", ret );
1282  assert( !ok );
1283  assert( ret == 0 );
1284 
1285  ok = extractIndex( "oops[0]]", ret );
1286  assert( !ok );
1287  assert( ret == 0 );
1288 
1289  ok = extractIndex( "fine [ 123 ]", ret );
1290  assert( ok );
1291  assert( ret == 123 );
1292 
1293  cout << "." << flush;
1294 }
bool extractIndex(const string &s, unsigned int &index)
Definition: Shell.cpp:423

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testFilterOffNodeTargets ( )

Definition at line 1716 of file testShell.cpp.

References ALLDATA, Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::element(), Id::eref(), filterOffNodeTargets(), MooseBlockBalance, myNode, and Shell::numNodes().

Referenced by testMpiShell(), and testShell().

1717 {
1718  Eref sheller = Id().eref();
1719  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
1720  unsigned int numSrcData = 6; // # entries in src of msg.
1721  unsigned int numData = 6; // Number of entries in msg destination elm.
1722 
1723  vector< vector< Eref > > origErefs( numSrcData );
1724  // erefs[ srcDataId ][entries]: targets for each dataIndex.
1725  vector< vector< bool > > origTargetNodes( numSrcData );
1726  // targetNodes[srcDataId][node]
1727 
1728  Id neuronId = shell->doCreate( "IntFire", Id(), "neurons", numData,
1730  Element* elm = neuronId.element();
1731  unsigned int numPerSrcNode = 1 + ( numSrcData - 1 ) / Shell::numNodes();
1732  unsigned int numPerNode = 1 + ( numData - 1 ) / Shell::numNodes();
1733 
1734  for ( unsigned int i = 0; i < numSrcData; ++i ) {
1735  origTargetNodes[i].resize( Shell::numNodes(), false );
1736  for ( unsigned int j = 0; j < i && j < numData; ++j )
1737  origErefs[i].push_back( Eref (elm, j ) );
1738  }
1739 
1740  for ( unsigned int myNode = 0; myNode < Shell::numNodes(); ++myNode ){
1741  vector< vector< Eref > > erefs = origErefs;
1742  vector< vector< bool > > targetNodes = origTargetNodes;
1743 
1745  0, numSrcData,
1746  false, myNode, erefs, targetNodes );
1747  for ( unsigned int i = 0; i < numSrcData; ++i ) {
1748  unsigned int sz = 0;
1749  // cout << endl << i << ": ";
1750  if ( i > numPerSrcNode * myNode ) {
1751  unsigned int j = i - numPerNode * myNode;
1752  if ( j > numPerNode )
1753  sz = numPerNode;
1754  else
1755  sz = j;
1756  }
1757  assert( erefs[i].size() == sz );
1758  // cout << "(" << sz << ", " << erefs[i].size() << "), ";
1759  for ( unsigned int j = 0; j < erefs[i].size(); ++j )
1760  assert( erefs[i][j].getNode() == myNode );
1761 
1762  for ( unsigned int j = 0; j < Shell::numNodes(); ++j ) {
1763  if ( j == myNode )
1764  assert( targetNodes[i][j] == false );
1765  else
1766  assert( targetNodes[i][j] == ( i > j * numPerNode ) );
1767  }
1768  }
1769  }
1770 
1771  for ( unsigned int i = 0; i < numSrcData; ++i ) {
1772  origTargetNodes[i].clear();
1773  origTargetNodes[i].resize( Shell::numNodes(), false );
1774  origErefs[i].clear();
1775  origErefs[i].push_back( Eref (elm, ALLDATA ) );
1776  }
1777  for ( unsigned int myNode = 0; myNode < Shell::numNodes(); ++myNode ){
1778  vector< vector< Eref > > erefs = origErefs;
1779  vector< vector< bool > > targetNodes = origTargetNodes;
1780  // cout << "\nmyNode = " << myNode << endl;
1781 
1782  unsigned int start = numPerSrcNode * myNode;
1783  unsigned int end = start + 1+ (numSrcData-1) % numPerSrcNode;
1785  start, end,
1786  false, myNode, erefs, targetNodes );
1787  for ( unsigned int i = 0; i < numData; ++i ) {
1788  // assert( erefs[i].size() == 1 );
1789  // The above should be true, except that this test always
1790  // runs on node 0 and Erefs refer to the system myNode to
1791  // find where they are.
1792  assert( erefs[i].size() == ( myNode == 0 ) );
1793  // cout << "\n i = " << i << ", sz=" << erefs[i].size();
1794  for ( unsigned int j = 0; j < erefs[i].size(); ++j )
1795  assert( erefs[i][j].getNode() == myNode );
1796 
1797  // Rule is : msgs sourced here that go off-node.
1798  // This works despite the system myNode, because in ALLDATA
1799  // we do a special lookup.
1800  for ( unsigned int j = 0; j < Shell::numNodes(); ++j ) {
1801  // sourced here: i / numPerNode == myNode
1802  if ( i / numPerNode == myNode && j != myNode )
1803  assert( targetNodes[i][j] == true );
1804  else
1805  assert( targetNodes[i][j] == false );
1806  // cout << "\ntargetNodes[" << i << "][" << j << "] = " << targetNodes[i][j];
1807  }
1808  }
1809  }
1810 
1811  cout << "." << flush;
1812 
1813  shell->doDelete( neuronId );
1814 }
char * data() const
Definition: Eref.cpp:41
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
static unsigned int myNode
void filterOffNodeTargets(unsigned int start, unsigned int end, bool isSrcGlobal, unsigned int myNode, vector< vector< Eref > > &erefs, vector< vector< bool > > &targetNodes)
Definition: Element.cpp:429
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static unsigned int numNodes()
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testFindModelParent ( )

Definition at line 1380 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::eref(), findModelParent(), and path.

Referenced by testMpiShell().

1381 {
1382  bool findModelParent( Id cwe, const string& path,
1383  Id& parentId, string& modelName );
1384 
1385  Eref sheller = Id().eref();
1386  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
1387 
1389  // Set up the objects.
1391  Id foo = shell->doCreate( "Neutral", Id(), "foo", 1 );
1392  Id zod = shell->doCreate( "Neutral", Id(), "zod", 1 );
1393  Id foo2 = shell->doCreate( "Neutral", zod, "foo", 1 );
1394 
1395  // shell->setCwe( zod );
1396 
1397  string modelName;
1398  Id parentId;
1399 
1401  bool ok = findModelParent( zod, "", parentId, modelName );
1402  assert( ok );
1403  assert( parentId == zod );
1404  assert( modelName == "model" );
1405  modelName = "";
1406 
1407  ok = findModelParent( zod, "/", parentId, modelName );
1408  assert( ok );
1409  assert( parentId == Id() );
1410  assert( modelName == "model" );
1411  modelName = "";
1412 
1413  ok = findModelParent( zod, "/foo", parentId, modelName );
1414  assert( ok );
1415  assert( parentId == Id() );
1416  assert( modelName == "foo" );
1417  modelName = "";
1418 
1419  ok = findModelParent( zod, "foo", parentId, modelName );
1420  assert( ok );
1421  assert( parentId == zod );
1422  assert( modelName == "foo" );
1423  modelName = "";
1424 
1426  ok = findModelParent( zod, "bar", parentId, modelName );
1427  assert( ok );
1428  assert( parentId == zod );
1429  assert( modelName == "bar" );
1430  modelName = "";
1431 
1432  ok = findModelParent( zod, "/bar", parentId, modelName );
1433  assert( ok );
1434  assert( parentId == Id() );
1435  assert( modelName == "bar" );
1436  modelName = "";
1437 
1438  ok = findModelParent( foo, "/foo/bar", parentId, modelName );
1439  assert( ok );
1440  assert( parentId == foo );
1441  assert( modelName == "bar" );
1442  modelName = "";
1443 
1444  ok = findModelParent( zod, "foo/bar", parentId, modelName );
1445  assert( ok );
1446  assert( parentId == foo2 );
1447  assert( modelName == "bar" );
1448 
1449  shell->doDelete( foo );
1450  shell->doDelete( foo2 );
1451  shell->doDelete( zod );
1452  cout << "." << flush;
1453 }
char * data() const
Definition: Eref.cpp:41
bool findModelParent(Id cwe, const string &path, Id &parentId, string &modelName)
Definition: LoadModels.cpp:81
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static char path[]
Definition: mfield.cpp:403
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testGetMsgs ( )

Tests message inspection fields on Neutral. These include msgOut: all outgoing Msgs, reported as ObjId of their managers msgIn: all incoming Msgs, reported as ObjId of their managers msgSrc: All source Ids of messages coming into specified field msgDest: All dest Ids of messages going out of specified field

Definition at line 1518 of file testShell.cpp.

References Eref::data(), Shell::doAddMsg(), Shell::doCreate(), Shell::doDelete(), and Id::eref().

Referenced by testShell().

1519 {
1520  Eref sheller = Id().eref();
1521  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
1522  unsigned int numData = 5;
1523 
1525  // Set up the objects.
1527  Id a1 = shell->doCreate( "Arith", Id(), "a1", numData );
1528  Id a2 = shell->doCreate( "Arith", Id(), "a2", numData );
1529 
1530  Id b1 = shell->doCreate( "Arith", Id(), "b1", numData );
1531  Id b2 = shell->doCreate( "Arith", Id(), "b2", numData );
1532 
1533  Id c1 = shell->doCreate( "Arith", Id(), "c1", numData );
1534  Id c2 = shell->doCreate( "Arith", Id(), "c2", numData );
1535 
1536  Id d1 = shell->doCreate( "Arith", Id(), "d1", numData );
1537  Id d2 = shell->doCreate( "Arith", Id(), "d2", numData );
1538 
1539  Id e1 = shell->doCreate( "Arith", Id(), "e1", numData );
1540  Id e2 = shell->doCreate( "Arith", Id(), "e2", numData );
1541 
1543  // Set up messaging
1545  // Should give 04000
1546  ObjId m1 = shell->doAddMsg( "Single",
1547  ObjId( a1, 3 ), "output", ObjId( a2, 1 ), "arg3" );
1548  assert( m1 != ObjId() );
1549 
1550  // Should give 33333
1551  ObjId m2 = shell->doAddMsg( "OneToAll",
1552  ObjId( a1, 2 ), "output", ObjId( b2, 0 ), "arg3" );
1553  assert( m2 != ObjId() );
1554 
1555  // Should give 12345
1556  ObjId m3 = shell->doAddMsg( "OneToOne",
1557  ObjId( a1, 0 ), "output", ObjId( c2, 0 ), "arg3" );
1558  assert( m3 != ObjId() );
1559 
1560  // Should give 01234
1561  ObjId m4 = shell->doAddMsg( "Diagonal",
1562  ObjId( a1, 0 ), "output", ObjId( d2, 0 ), "arg3" );
1563  assert( m4 != ObjId() );
1564 
1565  // Should give 54321
1566  ObjId m5 = shell->doAddMsg( "Sparse",
1567  ObjId( a1, 0 ), "output", ObjId( e2, 0 ), "arg3" );
1568  assert( m5 != ObjId() );
1569 
1571  // Check that the outgoing Msgs are OK.
1573  // Nov 2013: Wait till the Msg ObjIds are set up.
1574  /*
1575 
1576  vector< ObjId > msgMgrs =
1577  Field< vector< ObjId > >::get( a1, "msgOut" );
1578  assert( msgMgrs.size() == 5 ); // 5 above.
1579  for ( unsigned int i = 0; i < 5; ++i )
1580  assert( Field< Id >::get( msgMgrs[i], "e1" ) == a1 );
1581 
1582  assert( Field< string >::get( msgMgrs[0], "className" ) == "SingleMsg" );
1583  assert( Field< string >::get( msgMgrs[1], "className" ) == "OneToAllMsg" );
1584  assert( Field< string >::get( msgMgrs[2], "className" ) == "OneToOneMsg" );
1585  assert( Field< string >::get( msgMgrs[3], "className" ) == "DiagonalMsg" );
1586  assert( Field< string >::get( msgMgrs[4], "className" ) == "SparseMsg" );
1587 
1588  assert( Field< Id >::get( msgMgrs[0], "e2" ) == a2 );
1589  assert( Field< Id >::get( msgMgrs[1], "e2" ) == b2 );
1590  assert( Field< Id >::get( msgMgrs[2], "e2" ) == c2 );
1591  assert( Field< Id >::get( msgMgrs[3], "e2" ) == d2 );
1592  assert( Field< Id >::get( msgMgrs[4], "e2" ) == e2 );
1593  cout << "." << flush;
1594 
1596  // Check that the incoming Msgs are OK.
1598  msgMgrs = Field< vector< ObjId > >::get( a1, "msgIn" );
1599  assert( msgMgrs.size() == 1 ); // parent msg
1600  assert( msgMgrs[0].id == OneToAllMsg::managerId_ );
1601 
1602  assert( Field< Id >::get( msgMgrs[0], "e1" ) == Id() );
1603  assert( Field< Id >::get( msgMgrs[0], "e2" ) == a1 );
1604 
1605  msgMgrs = Field< vector< ObjId > >::get( a2, "msgIn" );
1606  assert( msgMgrs.size() == 2 ); // parent msg + input msg
1607  assert( Field< Id >::get( msgMgrs[0], "e1" ) == Id() );
1608  assert( Field< Id >::get( msgMgrs[0], "e2" ) == a2 );
1609  assert( Field< Id >::get( msgMgrs[1], "e1" ) == a1 );
1610  assert( Field< Id >::get( msgMgrs[1], "e2" ) == a2 );
1611 
1612  msgMgrs = Field< vector< ObjId > >::get( b2, "msgIn" );
1613  assert( msgMgrs.size() == 2 ); // parent msg + input msg
1614  assert( Field< Id >::get( msgMgrs[0], "e1" ) == Id() );
1615  assert( Field< Id >::get( msgMgrs[0], "e2" ) == b2 );
1616  assert( Field< Id >::get( msgMgrs[1], "e1" ) == a1 );
1617  assert( Field< Id >::get( msgMgrs[1], "e2" ) == b2 );
1618 
1619  msgMgrs = Field< vector< ObjId > >::get( c2, "msgIn" );
1620  assert( msgMgrs.size() == 2 ); // parent msg + input msg
1621  assert( Field< Id >::get( msgMgrs[0], "e1" ) == Id() );
1622  assert( Field< Id >::get( msgMgrs[0], "e2" ) == c2 );
1623  assert( Field< Id >::get( msgMgrs[1], "e1" ) == a1 );
1624  assert( Field< Id >::get( msgMgrs[1], "e2" ) == c2 );
1625 
1626  msgMgrs = Field< vector< ObjId > >::get( d2, "msgIn" );
1627  assert( msgMgrs.size() == 2 ); // parent msg + input msg
1628  assert( Field< Id >::get( msgMgrs[0], "e1" ) == Id() );
1629  assert( Field< Id >::get( msgMgrs[0], "e2" ) == d2 );
1630  assert( Field< Id >::get( msgMgrs[1], "e1" ) == a1 );
1631  assert( Field< Id >::get( msgMgrs[1], "e2" ) == d2 );
1632 
1633  msgMgrs = Field< vector< ObjId > >::get( e2, "msgIn" );
1634  assert( msgMgrs.size() == 2 ); // parent msg + input msg
1635  assert( Field< Id >::get( msgMgrs[0], "e1" ) == Id() );
1636  assert( Field< Id >::get( msgMgrs[0], "e2" ) == e2 );
1637  assert( Field< Id >::get( msgMgrs[1], "e1" ) == a1 );
1638  assert( Field< Id >::get( msgMgrs[1], "e2" ) == e2 );
1639  cout << "." << flush;
1640  */
1641 
1643  // Check that the MsgSrcs are OK.
1645  vector< Id > srcIds;
1646  srcIds = LookupField< string, vector< Id > >::get( a2, "neighbors", "arg3" );
1647  assert( srcIds.size() == 1 );
1648  assert( srcIds[0] == a1 );
1649  srcIds.resize( 0 );
1650  srcIds = LookupField< string, vector< Id > >::get( b2, "neighbors", "arg3" );
1651  assert( srcIds.size() == 1 );
1652  assert( srcIds[0] == a1 );
1653  srcIds.resize( 0 );
1654  srcIds = LookupField< string, vector< Id > >::get( c2, "neighbors", "arg3" );
1655  assert( srcIds.size() == 1 );
1656  assert( srcIds[0] == a1 );
1657 
1658  ObjId m6 = shell->doAddMsg( "Single",
1659  ObjId( b1, 3 ), "output", ObjId( b2, 1 ), "arg3" );
1660  assert( m6 != ObjId() );
1661  srcIds.resize( 0 );
1662  srcIds = LookupField< string, vector< Id > >::get( b2, "neighbors", "arg3" );
1663  assert( srcIds.size() == 2 );
1664  assert( srcIds[0] == a1 );
1665  assert( srcIds[1] == b1 );
1666  cout << "." << flush;
1667 
1669  // Check that the MsgDests are OK.
1671  vector< Id > destIds;
1672  destIds = LookupField< string, vector< Id > >::get( a1, "neighbors", "output" );
1673  assert( destIds.size() == 5 );
1674  assert( destIds[0] == a2 );
1675  assert( destIds[1] == b2 );
1676  assert( destIds[2] == c2 );
1677  assert( destIds[3] == d2 );
1678  assert( destIds[4] == e2 );
1679  destIds.resize( 0 );
1680  destIds = LookupField< string, vector< Id > >::get( b1, "neighbors", "output" );
1681  assert( destIds.size() == 1 );
1682  assert( destIds[0] == b2 );
1683  cout << "." << flush;
1684 
1686  // Clean up.
1688 
1689 
1690  shell->doDelete( a1 );
1691  shell->doDelete( a2 );
1692  shell->doDelete( b1 );
1693  shell->doDelete( b2 );
1694  shell->doDelete( c1 );
1695  shell->doDelete( c2 );
1696  shell->doDelete( d1 );
1697  shell->doDelete( d2 );
1698  shell->doDelete( e1 );
1699  shell->doDelete( e2 );
1700 }
char * data() const
Definition: Eref.cpp:41
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Definition: Eref.h:26
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
Definition: Shell.cpp:269
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testGetMsgSrcAndTarget ( )

Definition at line 1702 of file testShell.cpp.

Referenced by testShell().

1703 {
1704  // cout << "." << flush;
1705 }

+ Here is the caller graph for this function:

void testInterNodeOps ( )

Tests Shell operations carried out on multiple nodes

Definition at line 708 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::eref(), and Shell::myNode().

Referenced by testMpiShell().

709 {
710  Eref sheller = Id().eref();
711  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
712  Id child;
713  if ( shell->myNode() == 0 ) {
714  unsigned int size = 6139;
715  child = shell->doCreate( "Neutral", Id(), "test", size );
716  }
717  // cout << shell->myNode() << ": testInterNodeOps: #entries = " << child()->dataHandler()->numData() << endl;
718 
719  shell->doDelete( child );
720  // child.destroy();
721  cout << "." << flush;
722 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static unsigned int myNode()
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testMove ( )

Definition at line 323 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), Shell::doMove(), Id::eref(), Field< A >::get(), Neutral::getChildren(), path, and verifyKids().

Referenced by testMpiShell().

324 {
325  Eref sheller = Id().eref();
326  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
327 
328 
329  Id f1 = shell->doCreate( "Neutral", Id(), "f1", 1 );
330  Id f2a = shell->doCreate( "Neutral", f1, "f2a", 1 );
331  Id f2b = shell->doCreate( "Neutral", f1, "f2b", 1 );
332  Id f3 = shell->doCreate( "Neutral", f2a, "f3", 1 );
333  Id f4a = shell->doCreate( "Neutral", f3, "f4a", 1 );
334  Id f4b = shell->doCreate( "Neutral", f3, "f4b", 1 );
335  verifyKids( f1, f2a, f2b, f3, f4a, f4b );
336 
337  ObjId pa = Field< ObjId >::get( f4a, "parent" );
338  assert( pa == ObjId( f3, 0 ) );
339  pa = Field< ObjId >::get( f2a, "parent" );
340  assert( pa == ObjId( f1, 0 ) );
341  string path = Field< string >::get( f4a, "path" );
342  assert( path == "/f1[0]/f2a[0]/f3[0]/f4a[0]" );
343  Neutral* f1data = reinterpret_cast< Neutral* >( f1.eref().data() );
344 
345  vector< Id > kids = f1data->getChildren( f1.eref() );
346  assert( kids.size() == 2 );
347  assert( kids[0] == f2a );
348  assert( kids[1] == f2b );
349 
350  Neutral* f3data = reinterpret_cast< Neutral* >( f3.eref().data() );
351  kids = f3data->getChildren( f3.eref() );
352  assert( kids.size() == 2 );
353  assert( kids[0] == f4a );
354  assert( kids[1] == f4b );
355 
357  shell->doMove( f4a, f1 );
359 
360  pa = Field< ObjId >::get( f4a, "parent" );
361  assert( pa == ObjId( f1, 0 ) );
362 
363  kids = f1data->getChildren( f1.eref() );
364  assert( kids.size() == 3 );
365  assert( kids[0] == f2a );
366  assert( kids[1] == f2b );
367  assert( kids[2] == f4a );
368  kids = f3data->getChildren( f3.eref() );
369  assert( kids.size() == 1 );
370  assert( kids[0] == f4b );
371 
373  shell->doMove( f2a, f4a );
375  pa = Field< ObjId >::get( f2a, "parent" );
376  assert( pa == ObjId( f4a, 0 ) );
377  path = Field< string >::get( f4b, "path" );
378  assert( path == "/f1[0]/f4a[0]/f2a[0]/f3[0]/f4b[0]" );
379 
380  kids = f1data->getChildren( f1.eref() );
381  assert( kids[0] == f2b );
382  assert( kids[1] == f4a );
383 
384  shell->doDelete( f1 );
385  cout << "." << flush;
386 }
char * data() const
Definition: Eref.cpp:41
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
vector< Id > getChildren(const Eref &e) const
Definition: Neutral.cpp:334
void verifyKids(Id f1, Id f2a, Id f2b, Id f3, Id f4a, Id f4b)
Utility function to check a commonly used tree structure.
Definition: testShell.cpp:266
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static char path[]
Definition: mfield.cpp:403
Definition: Shell.h:43
void doMove(Id orig, ObjId newParent)
Definition: Shell.cpp:390

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testMpiShell ( )

Definition at line 1833 of file testShell.cpp.

References testChildren(), testCopy(), testCopyFieldElement(), testCopyMsgOps(), testDescendant(), testFilterOffNodeTargets(), testFindModelParent(), testInterNodeOps(), testMove(), testObjIdToAndFromPath(), testShellAddMsg(), testShellParserCreateDelete(), testShellSetGet(), testSyncSynapseSize(), testTreeTraversal(), and testWildcard().

Referenced by mpiTests().

1834 {
1838  testChildren();
1839  testDescendant();
1840  testMove();
1841  testCopy();
1843 
1845  // testMultiLevelCopyAndPath(); // Uses HH channels.
1846 
1847  testShellSetGet();
1848  testInterNodeOps();
1849  testShellAddMsg();
1850  testCopyMsgOps();
1851  testWildcard();
1853  // Stuff for doLoadModel
1855  cout << "." << flush;
1856 }
void testFindModelParent()
Definition: testShell.cpp:1380
void testShellSetGet()
Definition: testShell.cpp:724
void testCopyMsgOps()
Definition: testShell.cpp:1083
void testWildcard()
Definition: Wildcard.cpp:591
void testChildren()
Test the Neutral::children and buildTree.
Definition: testShell.cpp:290
void testShellParserCreateDelete()
Definition: testShell.cpp:31
void testShellAddMsg()
Definition: testShell.cpp:836
void testCopy()
Definition: testShell.cpp:388
void testCopyFieldElement()
Definition: testShell.cpp:440
void testFilterOffNodeTargets()
Definition: testShell.cpp:1716
void testObjIdToAndFromPath()
Definition: testShell.cpp:549
void testSyncSynapseSize()
Definition: testShell.cpp:1455
void testDescendant()
Test the Neutral::isDescendant.
Definition: testShell.cpp:234
void testTreeTraversal()
Definition: testShell.cpp:45
void testMove()
Definition: testShell.cpp:323
void testInterNodeOps()
Definition: testShell.cpp:708

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testObjIdToAndFromPath ( )

Definition at line 549 of file testShell.cpp.

References Eref::data(), ObjId::dataIndex, Shell::doCreate(), Shell::doDelete(), Shell::doMove(), doubleEq(), ObjId::eref(), Id::eref(), ObjId::fieldIndex, Field< A >::get(), ObjId::id, Neutral::parent(), ObjId::path(), path, Field< A >::set(), and Id::value().

Referenced by testMpiShell().

550 {
551  Eref sheller = Id().eref();
552  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
553  unsigned int s1 = 10;
554  unsigned int s2 = 1;
555  unsigned int s3 = 23;
556  unsigned int s4 = 1;
557  unsigned int s5 = 9;
558  unsigned int index1 = 1;
559  unsigned int index2 = 0;
560  unsigned int index3 = 3;
561  unsigned int index4 = 0;
562  unsigned int index5 = 5;
563 
564  Id level1 = shell->doCreate( "SimpleSynHandler", Id(), "f1", s1 );
565  Id origSynId( level1.value() + 1 );
566 
567  // origSynId.element()->resizeField( 7, 8 );
568  Field< unsigned int >::set( ObjId( origSynId, 7 ), "numField", 8 );
569  ObjId origSynObj( origSynId, 7, 5 );
570  Field< double >::set( origSynObj, "weight", 1999.0 );
571  double wt = Field< double >::get( origSynObj, "weight" );
572  assert( doubleEq( wt, 1999.0 ) );
573  // char* origSynData = origSynId.element()->data( 7, 5 );
574  // assert( origSynData != 0 );
575  Id level2 = shell->doCreate( "Neutral",
576  ObjId( level1, index1 ), "f2", s2 );
577  Id level3 = shell->doCreate( "Neutral",
578  ObjId( level2, index2 ), "f3", s3 );
579  Id level4 = shell->doCreate( "Neutral",
580  ObjId( level3, index3 ), "f4", s4 );
581  Id level5 = shell->doCreate( "Neutral",
582  ObjId( level4, index4 ), "f5", s5 );
583 
584  ObjId oi( level5, index5 );
585  string path = oi.path();
586  assert( path == "/f1[1]/f2[0]/f3[3]/f4[0]/f5[5]" );
587 
588  ObjId readPath( path );
589  assert( readPath.id == level5 );
590  assert( readPath.dataIndex == index5 );
591 
592  ObjId f4 = Neutral::parent( oi.eref() );
593  path = f4.path();
594  assert( path == "/f1[1]/f2[0]/f3[3]/f4[0]" );
595 
596  ObjId f3 = Neutral::parent( f4.eref() );
597  path = f3.path();
598  assert( path == "/f1[1]/f2[0]/f3[3]" );
599 
600  ObjId f2 = Neutral::parent( f3.eref() );
601  path = f2.path();
602  assert( path == "/f1[1]/f2[0]" );
603 
604  ObjId f1 = Neutral::parent( f2.eref() );
605  path = f1.path();
606  assert( path == "/f1[1]" );
607 
608  ObjId f0 = Neutral::parent( f1.eref() );
609  path = f0.path();
610  assert( path == "/" );
611  assert( f0 == Id() );
612 
613  // Here check what happens with a move.
614  Id level6 = shell->doCreate( "Neutral", Id(), "foo", 1 );
615  Id level7 = shell->doCreate( "Neutral", level6, "bar", 1 );
616  Id level8 = shell->doCreate( "Neutral", level7, "zod", 1 );
617 
618  shell->doMove( level1, level8 );
619 
620  ObjId noi( "/foo/bar/zod/f1[1]/f2[0]/f3[3]/f4[0]/f5[5]" );
621  assert( noi.dataIndex == index5 );
622  assert( noi.id == level5 );
623  assert( noi == oi );
624 
625  ObjId syn( "/foo/bar/zod/f1[7]/synapse[5]" );
626  assert( syn.dataIndex == 7 );
627  assert( syn.fieldIndex == 5 );
628  assert( syn.id == origSynId );
629  // assert( syn.data() == origSynData );
630  wt = Field< double >::get( syn, "weight" );
631  assert( doubleEq( wt, 1999.0 ) );
632 
633  shell->doDelete( level6 );
634  cout << "." << flush;
635 }
char * data() const
Definition: Eref.cpp:41
static ObjId parent(const Eref &e)
Definition: Neutral.cpp:701
unsigned int value() const
Definition: Id.cpp:197
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
string path() const
Definition: ObjId.cpp:119
Definition: Eref.h:26
Eref eref() const
Definition: ObjId.cpp:66
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static char path[]
Definition: mfield.cpp:403
Definition: Shell.h:43
void doMove(Id orig, ObjId newParent)
Definition: Shell.cpp:390

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testShell ( )

Definition at line 1818 of file testShell.cpp.

References testChildren(), testChopPath(), testExtractIndices(), testFilterOffNodeTargets(), testGetMsgs(), testGetMsgSrcAndTarget(), testTreeTraversal(), and testWildcard().

Referenced by nonMpiTests().

1819 {
1821  testChopPath();
1823  testChildren();
1824  testWildcard();
1826  testGetMsgs(); // Tests getting Msg info from Neutral.
1828 
1829  // This is a multinode test, but only needs to run on master node.
1831 }
void testChopPath()
Definition: testShell.cpp:1345
void testWildcard()
Definition: Wildcard.cpp:591
void testChildren()
Test the Neutral::children and buildTree.
Definition: testShell.cpp:290
void testExtractIndices()
Definition: testShell.cpp:1257
void testGetMsgSrcAndTarget()
Definition: testShell.cpp:1702
void testFilterOffNodeTargets()
Definition: testShell.cpp:1716
void testTreeTraversal()
Definition: testShell.cpp:45
void testGetMsgs()
Definition: testShell.cpp:1518

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testShellAddMsg ( )

Definition at line 836 of file testShell.cpp.

References checkOutput(), Eref::data(), Shell::doAddMsg(), Shell::doCreate(), Shell::doDelete(), Shell::doSetClock(), Shell::doStart(), doubleEq(), Shell::doUseClock(), Eref::element(), ObjId::eref(), Id::eref(), Cinfo::findFinfo(), Field< A >::get(), Element::getNeighbors(), Field< A >::getVec(), init(), Clock::initCinfo(), SetGet3< A1, A2, A3 >::set(), and SetGet1< A >::setVec().

Referenced by testMpiShell().

837 {
838  Eref sheller = Id().eref();
839  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
840  unsigned int size = 5;
841 
842 
844  // Set up the objects.
846  Id a1 = shell->doCreate( "Arith", Id(), "a1", size );
847  Id a2 = shell->doCreate( "Arith", Id(), "a2", size );
848 
849  Id b1 = shell->doCreate( "Arith", Id(), "b1", size );
850  Id b2 = shell->doCreate( "Arith", Id(), "b2", size );
851 
852  Id c1 = shell->doCreate( "Arith", Id(), "c1", size );
853  Id c2 = shell->doCreate( "Arith", Id(), "c2", size );
854 
855  Id d1 = shell->doCreate( "Arith", Id(), "d1", size );
856  Id d2 = shell->doCreate( "Arith", Id(), "d2", size );
857 
858  Id e1 = shell->doCreate( "Arith", Id(), "e1", size );
859  Id e2 = shell->doCreate( "Arith", Id(), "e2", size );
860 
861  Id f1 = shell->doCreate( "Arith", Id(), "f1", size );
862  Id f2 = shell->doCreate( "Arith", Id(), "f2", size );
863 
864  Id g1 = shell->doCreate( "Arith", Id(), "g1", size );
865  Id g2 = shell->doCreate( "Arith", Id(), "g2", size );
866 
867 
869  // Set up messaging
871  // Should give 04000
872  ObjId m1 = shell->doAddMsg( "Single",
873  ObjId( a1, 3 ), "output", ObjId( a2, 1 ), "arg3" );
874  assert( m1 != ObjId() );
875 
876  // Should give 33333
877  ObjId m2 = shell->doAddMsg( "OneToAll",
878  ObjId( b1, 2 ), "output", ObjId( b2, 0 ), "arg3" );
879  assert( m2 != ObjId() );
880 
881  // Should give 12345
882  ObjId m3 = shell->doAddMsg( "OneToOne",
883  ObjId( c1, 0 ), "output", ObjId( c2, 0 ), "arg3" );
884  assert( m3 != ObjId() );
885 
886  // Should give 01234
887  ObjId m4 = shell->doAddMsg( "Diagonal",
888  ObjId( d1, 0 ), "output", ObjId( d2, 0 ), "arg3" );
889  assert( m4 != ObjId() );
890 
891  // Should give 54321
892  ObjId m5 = shell->doAddMsg( "Sparse",
893  ObjId( e1, 0 ), "output", ObjId( e2, 0 ), "arg3" );
894  assert( m5 != ObjId() );
895 
897  m5, "setEntry", 0, 4, 0 );
898  assert( ret );
900  m5, "setEntry", 1, 3, 0 );
901  assert( ret );
903  m5, "setEntry", 2, 2, 0 );
904  assert( ret );
906  m5, "setEntry", 3, 1, 0 );
907  assert( ret );
909  m5, "setEntry", 4, 0, 0 );
910  assert( ret );
911 
912  // Should give 15 15 15 15 15
913  for ( unsigned int i = 0; i < 5; ++i ) {
914  ObjId m6 = shell->doAddMsg( "OneToAll",
915  ObjId( f1, i ), "output", ObjId( f2, i ), "arg3" );
916  assert( m6 != ObjId() );
917  }
918 
919  // Should give 14 13 12 11 10
920  ObjId m7 = shell->doAddMsg( "Sparse",
921  ObjId( g1, 0 ), "output", ObjId( g2, 0 ), "arg3" );
922  assert( m7 != ObjId() );
923  for ( unsigned int i = 0; i < 5; ++i ) {
924  for ( unsigned int j = 0; j < 5; ++j ) {
925  if ( i != j ) {
927  m7, "setEntry", i, j, 0 );
928  assert( ret );
929  }
930  }
931  }
932 
934  // Set up scheduling
936  shell->doSetClock( 0, 1.0 );
937  shell->doSetClock( 9, 1.0 ); // Postmaster uses clock 9, always.
938 
939  ObjId clock( Id( 1 ), 0 );
940  // I want to compare the # of process msgs before and after.
941  vector< Id > tgts;
942  const SrcFinfo* sf = dynamic_cast< const SrcFinfo* >(
943  Clock::initCinfo()->findFinfo( "process0" ) );
944  assert( sf );
945  unsigned int numTgts = clock.eref().element()->getNeighbors( tgts, sf );
946  assert( numTgts == 0 );
947 
948  shell->doUseClock( "a1,a2,b1,b2,c1,c2,d1,d2,e1,e2,f1,f2,g1,g2", "process", 0 );
949  numTgts = clock.eref().element()->getNeighbors( tgts, sf );
950  assert( numTgts == 14 );
951 
953  // Set up initial conditions
955 
956  // shell->doReinit();
957 
958  vector< double > init; // 12345
959  for ( unsigned int i = 1; i < 6; ++i )
960  init.push_back( i );
961  ret = SetGet1< double >::setVec( a1, "arg1", init ); // 12345
962  assert( ret );
963  ret = SetGet1< double >::setVec( b1, "arg1", init ); // 12345
964  assert( ret );
965  ret = SetGet1< double >::setVec( c1, "arg1", init ); // 12345
966  assert( ret );
967  ret = SetGet1< double >::setVec( d1, "arg1", init ); // 12345
968  assert( ret );
969  ret = SetGet1< double >::setVec( e1, "arg1", init ); // 12345
970  assert( ret );
971  ret = SetGet1< double >::setVec( f1, "arg1", init ); // 12345
972  assert( ret );
973  ret = SetGet1< double >::setVec( g1, "arg1", init ); // 12345
974  assert( ret );
975 
976  double val = 0;
977  /*
978  * Silly to try to do this on multiple nodes. We don't know where
979  * the object may put its data entries.
980  val = (reinterpret_cast< const Arith* >( ObjId( a1, 0 ).data() ) )->getArg1();
981  assert( doubleEq( val, 1 ) );
982  val = (reinterpret_cast< const Arith* >( ObjId( a1, 1 ).data() ) )->getArg1();
983  assert( doubleEq( val, 2 ) );
984  */
985 
986  val = Field< double >::get( ObjId( a1, 0 ), "arg1Value" );
987  assert( doubleEq( val, 1 ) );
988  val = Field< double >::get( ObjId( a1, 1 ), "arg1Value" );
989  assert( doubleEq( val, 2 ) );
990  val = Field< double >::get( ObjId( a1, 2 ), "arg1Value" );
991  assert( doubleEq( val, 3 ) );
992  val = Field< double >::get( ObjId( a1, 3 ), "arg1Value" );
993  assert( doubleEq( val, 4 ) );
994  val = Field< double >::get( ObjId( a1, 4 ), "arg1Value" );
995  assert( doubleEq( val, 5 ) );
996 
997  for ( unsigned int i = 0; i < 5; ++i ) {
998  double x = Field< double >::get( ObjId( a1, i ), "arg1Value" );
999  assert( doubleEq( x, i + 1 ) );
1000  x = Field< double >::get( ObjId( b1, i ), "arg1Value" );
1001  assert( doubleEq( x, i + 1 ) );
1002  x = Field< double >::get( ObjId( c1, i ), "arg1Value" );
1003  assert( doubleEq( x, i + 1 ) );
1004  }
1005  vector< double > retVec( 0 );
1006  Field< double >::getVec( a1, "arg1Value", retVec );
1007  for ( unsigned int i = 0; i < 5; ++i )
1008  assert( doubleEq( retVec[i], i + 1 ) );
1009 
1010  retVec.resize( 0 );
1011  Field< double >::getVec( b1, "arg1Value", retVec );
1012  for ( unsigned int i = 0; i < 5; ++i )
1013  assert( doubleEq( retVec[i], i + 1 ) );
1014 
1015  retVec.resize( 0 );
1016  Field< double >::getVec( c1, "arg1Value", retVec );
1017  for ( unsigned int i = 0; i < 5; ++i )
1018  assert( doubleEq( retVec[i], i + 1 ) );
1019 
1020 
1022  // Run it
1024 
1025  shell->doStart( 2 );
1026 
1027  // Clock* clock = reinterpret_cast< Clock* >( Id(1).eref().data() );
1028  // clock->printCounts();
1029  // Qinfo::reportQ();
1030 
1032  // Check output.
1034 
1035  ret = checkOutput( a1, 1, 2, 3, 4, 5 );
1036  assert( ret );
1037  ret = checkOutput( b1, 1, 2, 3, 4, 5 );
1038  assert( ret );
1039  ret = checkOutput( c1, 1, 2, 3, 4, 5 );
1040  assert( ret );
1041  ret = checkOutput( d1, 1, 2, 3, 4, 5 );
1042  assert( ret );
1043  ret = checkOutput( e1, 1, 2, 3, 4, 5 );
1044  assert( ret );
1045  ret = checkOutput( a2, 0, 4, 0, 0, 0 );
1046  assert( ret );
1047  ret = checkOutput( b2, 3, 3, 3, 3, 3 );
1048  // assert( ret );
1049  ret = checkOutput( c2, 1, 2, 3, 4, 5 );
1050  // assert( ret );
1051  ret = checkOutput( d2, 0, 1, 2, 3, 4 );
1052  // assert( ret );
1053  ret = checkOutput( e2, 5, 4, 3, 2, 1 );
1054  // assert( ret );
1055  ret = checkOutput( f2, 15, 15, 15, 15, 15 );
1056  // assert( ret );
1057  ret = checkOutput( g2, 14, 13, 12, 11, 10 );
1058  assert( ret );
1059 
1061  // Clean up.
1063  shell->doDelete( a1 );
1064  shell->doDelete( a2 );
1065  shell->doDelete( b1 );
1066  shell->doDelete( b2 );
1067  shell->doDelete( c1 );
1068  shell->doDelete( c2 );
1069  shell->doDelete( d1 );
1070  shell->doDelete( d2 );
1071  shell->doDelete( e1 );
1072  shell->doDelete( e2 );
1073  shell->doDelete( f1 );
1074  shell->doDelete( f2 );
1075  shell->doDelete( g1 );
1076  shell->doDelete( g2 );
1077 
1078  cout << "." << flush;
1079 }
Id init(int argc, char **argv, bool &doUnitTests, bool &doRegressionTests, unsigned int &benchmark)
Definition: main.cpp:150
void doStart(double runtime, bool notify=false)
Definition: Shell.cpp:332
char * data() const
Definition: Eref.cpp:41
bool checkOutput(Id e, double v0, double v1, double v2, double v3, double v4)
Definition: testShell.cpp:795
void doSetClock(unsigned int tickNum, double dt)
Definition: Shell.cpp:377
static const Cinfo * initCinfo()
Definition: Clock.cpp:133
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
Definition: Eref.h:26
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
Definition: Shell.cpp:269
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3)
Definition: SetGet.h:626
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
void doUseClock(string path, string field, unsigned int tick)
Definition: Shell.cpp:382
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static void getVec(ObjId dest, const string &field, vector< A > &vec)
Definition: SetGet.h:317
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
Definition: SetGet.h:188
Definition: Shell.h:43
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testShellParserCreateDelete ( )

Tests Create and Delete calls issued through the parser interface, which internally sets up blocking messaging calls.

Definition at line 31 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), and Id::eref().

Referenced by testMpiShell().

32 {
33  Eref sheller = Id().eref();
34  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
35 
36  Id child = shell->doCreate( "Neutral", Id(), "test", 1 );
37 
38  shell->doDelete( child );
39  cout << "." << flush;
40 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testShellParserQuit ( )

Definition at line 1246 of file testShell.cpp.

References Eref::data(), Shell::doQuit(), and Id::eref().

1247 {
1248  Eref sheller = Id().eref();
1249  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
1250  shell->doQuit( );
1251  cout << "." << flush;
1252 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
Definition: Eref.h:26
void doQuit()
Definition: Shell.cpp:327
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

void testShellParserStart ( )

Definition at line 640 of file testShell.cpp.

References Eref::data(), Id::destroy(), Shell::doCreate(), Shell::doSetClock(), Shell::doStart(), Shell::doUseClock(), Id::eref(), MooseGlobal, and Shell::myNode().

641 {
642  Eref sheller = Id().eref();
643  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
644 
645  shell->doSetClock( 0, 5.0 );
646  shell->doSetClock( 1, 2.0 );
647  shell->doSetClock( 2, 2.0 );
648  shell->doSetClock( 3, 1.0 );
649  shell->doSetClock( 4, 3.0 );
650  shell->doSetClock( 5, 5.0 );
651 
652  Id tsid = shell->doCreate( "testSched", ObjId(), "tse", 1, MooseGlobal );
653 
654  /*
655  const Cinfo* testSchedCinfo = TestSched::initCinfo();
656  Id tsid = Id::nextId();
657  Element* tse = new GlobalDataElement( tsid, testSchedCinfo, "tse", 1 );
658  */
659  shell->doUseClock( "/tse", "process", 0 );
660  shell->doUseClock( "/tse", "process", 1 );
661  shell->doUseClock( "/tse", "process", 2 );
662  shell->doUseClock( "/tse", "process", 3 );
663  shell->doUseClock( "/tse", "process", 4 );
664  shell->doUseClock( "/tse", "process", 5 );
665 
666 
667  /*
668  // testThreadSchedElement tse;
669  Eref ts( tse, 0 );
670  Element* clocke = Id( 1 ).element();
671  Eref er0( clocke, DataId( 0 ) );
672  Eref er1( clocke, DataId( 1 ) );
673  Eref er2( clocke, DataId( 2 ) );
674  Eref er3( clocke, DataId( 3 ) );
675  Eref er4( clocke, DataId( 4 ) );
676  Eref er5( clocke, DataId( 5 ) );
677  */
678 
679  /*
680  // No idea what FuncId to use here. Assume 0.
681  FuncId f( 0 );
682  SingleMsg m0( er0, ts );
683  er0.element()->addMsgAndFunc( m0.mid(), f, 0 );
684  SingleMsg m1( er1, ts );
685  er1.element()->addMsgAndFunc( m1.mid(), f, 1 );
686  SingleMsg m2( er2, ts );
687  er2.element()->addMsgAndFunc( m2.mid(), f, 2 );
688  SingleMsg m3( er3, ts );
689  er3.element()->addMsgAndFunc( m3.mid(), f, 3 );
690  SingleMsg m4( er4, ts );
691  er4.element()->addMsgAndFunc( m4.mid(), f, 4 );
692  SingleMsg m5( er5, ts );
693  er5.element()->addMsgAndFunc( m5.mid(), f, 5 );
694  */
695 
696  if ( shell->myNode() != 0 )
697  return;
698 
699  shell->doStart( 10 );
700 
701  tsid.destroy();
702  cout << "." << flush;
703 }
void doStart(double runtime, bool notify=false)
Definition: Shell.cpp:332
char * data() const
Definition: Eref.cpp:41
void doSetClock(unsigned int tickNum, double dt)
Definition: Shell.cpp:377
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
void destroy() const
Definition: Id.cpp:176
Definition: Eref.h:26
Definition: Id.h:17
static unsigned int myNode()
void doUseClock(string path, string field, unsigned int tick)
Definition: Shell.cpp:382
Definition: Shell.h:43

+ Here is the call graph for this function:

void testShellSetGet ( )

Definition at line 724 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), doubleEq(), Id::eref(), Field< A >::get(), Field< A >::getVec(), SetGet1< A >::set(), and SetGet1< A >::setVec().

Referenced by testMpiShell().

725 {
726  Eref sheller = Id().eref();
727  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
728  const unsigned int size = 100;
729  vector< double > val;
730 
731  // Set up the objects.
732  Id a1 = shell->doCreate( "Arith", Id(), "a1", size );
733 
734  // cout << Shell::myNode() << ": testShellSetGet: data here = (" << a1()->dataHandler()->begin() << " to " << a1()->dataHandler()->end() << ")" << endl;
735  for ( unsigned int i = 0; i < size; ++i ) {
736  val.push_back( i * i * i ); // use i^3 as a simple test.
737  bool ret = SetGet1< double >::set( ObjId( a1, i ), "setOutputValue", i * i );
738  assert( ret );
739  }
740  for ( unsigned int i = 0; i < size; ++i ) {
741  double x = Field< double >::get( ObjId( a1, i ), "outputValue" );
742  assert( doubleEq( x, i * i ) );
743  }
744  bool ret = SetGet1< double >::setVec( a1, "setOutputValue", val );
745  assert( ret );
746  for ( unsigned int i = 0; i < size; ++i ) {
747  double x = Field< double >::get( ObjId( a1, i ), "outputValue" );
748  // cout << i << " x=" << x << " i^3=" << i * i * i << endl;
749  assert( doubleEq( x, i * i * i ) );
750  }
751 
752  val.clear();
753  Field< double >::getVec( a1, "outputValue", val );
754  for ( unsigned int i = 0; i < size; ++i ) {
755  assert( doubleEq( val[i], i * i * i ) );
756  }
757 
758  shell->doDelete( a1 );
759  cout << "." << flush;
760 }
char * data() const
Definition: Eref.cpp:41
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
Definition: Eref.h:26
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:153
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static void getVec(ObjId dest, const string &field, vector< A > &vec)
Definition: SetGet.h:317
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
Definition: SetGet.h:188
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testSyncSynapseSize ( )

Definition at line 1455 of file testShell.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), ObjId::element(), Id::eref(), Cinfo::find(), Cinfo::findFinfo(), Element::numField(), Shell::numNodes(), Field< A >::set(), Field< A >::setVec(), and Id::value().

Referenced by testMpiShell().

1456 {
1457  Eref sheller = Id().eref();
1458  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
1459  const Cinfo* c = Cinfo::find( "SimpleSynHandler" );
1460  const Finfo* f = c->findFinfo( "getNumSynapses" );
1461  const DestFinfo* df = dynamic_cast< const DestFinfo* >( f );
1462  assert( df );
1463  unsigned int size = 100;
1464  Id neuronId = shell->doCreate( "SimpleSynHandler", Id(), "handler", size );
1465  assert( neuronId != Id() );
1466  Id synId( neuronId.value() + 1 );
1467  Element* syn = synId.element();
1468 
1469  // Element should exist even if data doesn't
1470  assert ( syn != 0 );
1471  assert ( syn->getName() == "synapse" );
1472 
1473  assert( syn->numData() == size );
1474  vector< unsigned int > ns( size, 0 );
1475  for ( unsigned int i = 0; i < size; ++i )
1476  ns[i] = i;
1477  bool ret = Field< unsigned int >::setVec( neuronId, "numSynapses", ns);
1478  assert( ret );
1479  // Here we check local entries
1480 
1481  assert( Field< unsigned int >::get( neuronId, "numData" ) == size );
1482  assert( Field< unsigned int >::get( synId, "numData" ) == size );
1483  for ( unsigned int i = 0; i < size; ++i ) {
1484  ObjId oi( synId, i );
1485  assert( Field< unsigned int >::get( oi, "numField" ) == i );
1486 
1487  // low-level access only works on single node.
1488  if ( Shell::numNodes() == 1 )
1489  assert( oi.element()->numField( i ) == i );
1490 
1491  for ( unsigned int j = 0; j < i; ++j ) {
1492  ObjId temp( synId, i, j );
1493  Field< double >::set( temp, "delay", i * 1000 + j );
1494  }
1495  }
1496  /*
1497  vector< double > delay;
1498  Field< double >::getVec( synId, "delay", delay );
1499  assert( delay.size() == size * ( size - 1 ) / 2 );
1500  unsigned int k = 0;
1501  for ( unsigned int i = 0; i < size; ++i )
1502  for ( unsigned int j = 0; j < i; ++j )
1503  assert( doubleEq( delay[ k++ ], i * 1000 + j ) );
1504  */
1505 
1506  shell->doDelete( neuronId );
1507  cout << "." << flush;
1508 }
char * data() const
Definition: Eref.cpp:41
unsigned int value() const
Definition: Id.cpp:197
Definition: SetGet.h:236
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Definition: Eref.h:26
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
Definition: SetGet.h:252
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static unsigned int numNodes()
Definition: Cinfo.h:18
Definition: Shell.h:43
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testTreeTraversal ( )

Tests traversal through parents and siblings.

Definition at line 45 of file testShell.cpp.

References ALLDATA, ObjId::bad(), Neutral::child(), Eref::data(), Shell::doCreate(), Shell::doDelete(), Shell::doFind(), Id::element(), Id::eref(), Field< A >::get(), ObjId::id, ObjId::path(), Id::path(), path, Field< A >::set(), Shell::setCwe(), TEST_WARNING, and Id::value().

Referenced by testMpiShell(), and testShell().

46 {
47  Eref sheller = Id().eref();
48  Shell* shell = reinterpret_cast< Shell* >( sheller.data() );
49 
50  unsigned int i = 0;
51  Id f1 = shell->doCreate( "Neutral", Id(), "f1", 10 );
52  assert( f1 != Id() );
53  Id f2a = shell->doCreate( "Neutral", ObjId(f1, i++), "f2a", 10 );
54  assert( f2a != Id() );
55  Id f2b = shell->doCreate( "Neutral", ObjId(f1, i++), "f2b", 10 );
56  assert( f2b != Id() );
57  Id f2c = shell->doCreate( "Neutral", ObjId(f1, i++), "f2c", 10 );
58  assert( f2c != Id() );
59  Id f3aa = shell->doCreate( "Neutral", ObjId(f2a, i++), "f3aa", 10 );
60  assert( f3aa != Id() );
61  Id f3ab = shell->doCreate( "Neutral", ObjId(f2a, i++), "f3ab", 10 );
62  assert( f3ab != Id() );
63  Id f3ba = shell->doCreate( "Neutral", ObjId(f2b, i++), "f3ba", 10 );
64  assert( f3ba != Id() );
65  Id f4 = shell->doCreate( "IntFire", ObjId(f3ba, i++), "cell", 10 );
66  assert( f4 != Id() );
67  Id f5 = shell->doCreate( "SimpleSynHandler", ObjId(f4, i++), "syns", 10 );
68  assert( f5 != Id() );
69  Id syns( f5.value() + 1 );
70  for ( unsigned int i = 0; i < 10; ++i ) {
71  Field< unsigned int >::set( ObjId( f5, i ), "numSynapse", 5 );
72  }
73 
75  // Checking for own Ids
77  ObjId me = Field< ObjId >::get( f3aa, "me" );
78  assert( me == ObjId( f3aa, 0 ) );
79  me = Field< ObjId >::get( f3ba, "me" );
80  assert( me == ObjId( f3ba, 0 ) );
81  me = Field< ObjId >::get( f2c, "me" );
82  assert( me == ObjId( f2c, 0 ) );
83 
85  // Checking for parent Ids
87  ObjId pa = Field< ObjId >::get( f3aa, "parent" );
88  assert( pa == ObjId( f2a, 3 ) );
89  pa = Field< ObjId >::get( f3ab, "parent" );
90  assert( pa == ObjId( f2a, 4 ) );
91  pa = Field< ObjId >::get( f2b, "parent" );
92  assert( pa == ObjId( f1, 1 ) );
93  pa = Field< ObjId >::get( f1, "parent" );
94  assert( pa == ObjId( Id(), 0 ) );
95 
96  cout << "." << flush;
97 
99  // Checking for child Id lists
101  vector< Id > kids =
102  Field< vector< Id > >::get( ObjId( f1, 0 ), "children" );
103  assert( kids.size() == 1 );
104  assert( kids[0] == f2a );
105  kids = Field< vector< Id > >::get( ObjId( f1, 1 ), "children" );
106  assert( kids.size() == 1 );
107  assert( kids[0] == f2b );
108  kids = Field< vector< Id > >::get( ObjId( f1, 2 ), "children" );
109  assert( kids.size() == 1 );
110  assert( kids[0] == f2c );
111 
112  kids = Field< vector< Id > >::get( ObjId( f1, ALLDATA ), "children" );
113  assert( kids.size() == 3 );
114  assert( kids[0] == f2a );
115  assert( kids[1] == f2b );
116  assert( kids[2] == f2c );
117 
118  kids = Field< vector< Id > >::get( ObjId( f2a, ALLDATA ), "children" );
119  assert( kids.size() == 2 );
120  assert( kids[0] == f3aa );
121  assert( kids[1] == f3ab );
122 
123  kids = Field< vector< Id > >::get( ObjId( f2b, 0 ), "children" );
124  assert( kids.size() == 0 );
125  kids = Field< vector< Id > >::get( ObjId( f2b, 5 ), "children" );
126  assert( kids.size() == 1 );
127  assert( kids[0] == f3ba );
128 
129  kids = Field< vector< Id > >::get( f2c, "children" );
130  assert( kids.size() == 0 );
131 
132  cout << "." << flush;
133 
135  // Checking Id::path and ObjId::path
137  string path = syns.path();
138  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[0]/synapse" );
139  ObjId oi( syns, 8, 3 );
140  path = oi.path();
141  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[8]/synapse[3]" );
142  path = oi.id.path();
143  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[0]/synapse" );
144 
145  ObjId oi2( f4, 4 );
146  path = oi2.path();
147  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[4]" );
148  path = oi2.id.path();
149  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell" );
150 
151  cout << "." << flush;
152 
154  // Checking path string generation.
156  path = Field< string >::get( f3aa, "path" );
157  assert( path == "/f1[0]/f2a[3]/f3aa[0]" );
158  path = Field< string >::get( f3ab, "path" );
159  assert( path == "/f1[0]/f2a[4]/f3ab[0]" );
160  path = Field< string >::get( f3ba, "path" );
161  assert( path == "/f1[1]/f2b[5]/f3ba[0]" );
162  path = Field< string >::get( f4, "path" );
163  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[0]" );
164  path = Field< string >::get( syns, "path" );
165  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[0]/synapse[0]" );
166  path = Field< string >::get( ObjId( syns, 8, 3 ), "path" );
167  assert( path == "/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[8]/synapse[3]" );
168 
169  path = Field< string >::get( ObjId( f2a, 7 ), "path" );
170  assert( path == "/f1[0]/f2a[7]" );
171  path = Field< string >::get( ObjId( f2b, 2 ), "path" );
172  assert( path == "/f1[1]/f2b[2]" );
173  path = Field< string >::get( f2c, "path" );
174  assert( path == "/f1[2]/f2c[0]" );
175  path = Field< string >::get( f1, "path" );
176  assert( path == "/f1[0]" );
177  path = Field< string >::get( Id(), "path" );
178  assert( path == "/" );
179 
180  path = Field< string >::get( Id(), "path" );
181 
182  cout << "." << flush;
184  // Checking finding Ids from path
186 
187  shell->setCwe( Id() );
188  assert( shell->doFind( "/f1/f2a/tralalalala" ).bad() );
189  assert( shell->doFind( "/f1/f2a[723]/f3aa" ).bad() );
190  assert( shell->doFind( "/f1/f2a/f3aa[12]" ).bad() );
191  if ( TEST_WARNING ) {
192  cout << "\nTesting warning for bad path indexing: ";
193  assert( shell->doFind( "/f1/f2a/f3aa[-1]" ).bad() );
194  }
195  ObjId ret = shell->doFind( "/f1/f2a[3]/f3aa" );
196  assert( ret == f3aa );
197  ret = shell->doFind( "/f1/f2a[4]/f3ab" );
198  assert( ret == f3ab );
199  ret = shell->doFind( "/f1[1]/f2b[5]/f3ba" );
200  assert( ret == f3ba );
201  ret = shell->doFind( "/f1[1]/f2b[5]/f3ba[6]" );
202  assert( ret == ObjId( f3ba, 6 ) );
203  ret = shell->doFind( "/f1[1]/f2b[5]/f3ba/.." );
204  assert( ret == ObjId( f2b, 5 ) );
205  assert( shell->doFind( "f1[1]/f2b[5]/f3ba" ) == f3ba );
206  assert( shell->doFind( "./f1[1]/f2b[5]/f3ba" ) == f3ba );
207  assert( shell->doFind( "./f1[1]/f2b/.." ) == ObjId( f1, 1 ) );
208 
209  shell->setCwe( ObjId( f2b, 5 ) );
210  assert( shell->doFind( "." ) == ObjId( f2b, 5 ) );
211  assert( shell->doFind( "f3ba" ) == f3ba );
212  assert( shell->doFind( "f3ba[7]" ) == ObjId( f3ba, 7 ) );
213  assert( shell->doFind( "f3ba/" ) == f3ba );
214  assert( shell->doFind( "f3ba/.." ) == ObjId( f2b, 5 ) );
215  // assert( shell->doFind( "f3ba/../../f2a[3]/f3aa" ) == f3aa );
216  assert( shell->doFind( "f3ba/../../" ) == ObjId( f1, 1 ) );
217  assert( shell->doFind( "../../f1/f2a[4]/f3ab" ) == f3ab );
218  // assert( shell->doFind( "../f2a[4]/f3ab" ) == f3ab );
219 
220  cout << "." << flush;
222  // Checking getChild
224  // Neutral* f1data = reinterpret_cast< Neutral* >( f1.eref().data() );
225  assert( f2a == Neutral::child( Eref( f1.element(), 0 ), "f2a" ) );
226  assert( f2b == Neutral::child( Eref( f1.element(), 1 ), "f2b" ) );
227  assert( f2c == Neutral::child( Eref( f1.element(), 2 ), "f2c" ) );
228  shell->setCwe( Id() );
229  shell->doDelete( f1 );
230  cout << "." << flush;
231 }
char * data() const
Definition: Eref.cpp:41
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
bool bad() const
Definition: ObjId.cpp:18
unsigned int value() const
Definition: Id.cpp:197
Definition: SetGet.h:236
static Id child(const Eref &e, const string &name)
Definition: Neutral.cpp:665
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
ObjId doFind(const string &path) const
Definition: Shell.cpp:549
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
Definition: Eref.h:26
const bool TEST_WARNING
Definition: testShell.cpp:25
void setCwe(ObjId cwe)
Definition: Shell.cpp:610
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
static char path[]
Definition: mfield.cpp:403
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testWildcard ( )

Definition at line 591 of file Wildcard.cpp.

References alignedSingleWildcardMatch(), ALLDATA, Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::eref(), findBraceContent(), findWithSingleCharWildcard(), matchBeforeBrace(), matchInsideBrace(), name, Field< A >::set(), simpleWildcardFind(), and wildcardTestFunc().

Referenced by testMpiShell(), and testShell().

592 {
593  unsigned long i;
594  string bb;
595  string ib;
596  i = findBraceContent( "foo[23][TYPE=Compartment]", bb, ib );
597  assert( bb == "foo" );
598  assert( i == 23 );
599  assert( ib == "TYPE=Compartment" );
600  i = findBraceContent( "foo[][TYPE=Channel]", bb, ib );
601  assert( i == ALLDATA );
602  assert( bb == "foo" );
603  assert( ib == "TYPE=Channel" );
604  i = findBraceContent( "foo[TYPE=membrane]", bb, ib );
605  assert( i == 0 );
606  assert( bb == "foo" );
607  assert( ib == "TYPE=membrane" );
608  i = findBraceContent( "bar[]", bb, ib );
609  assert( i == ALLDATA );
610  assert( bb == "bar" );
611  assert( ib == "" );
612  i = findBraceContent( "zod[24]", bb, ib );
613  assert( i == 24 );
614  assert( bb == "zod" );
615  assert( ib == "" );
616 
617  i = findBraceContent( "zod#", bb, ib );
618  assert( i == ALLDATA );
619  assert( bb == "zod#" );
620  assert( ib == "" );
621  i = findBraceContent( "zod#[]", bb, ib );
622  assert( i == ALLDATA );
623  assert( bb == "zod#" );
624  assert( ib == "" );
625  i = findBraceContent( "zod#[ISA=hippo]", bb, ib );
626  assert( i == ALLDATA );
627  assert( bb == "zod#" );
628  assert( ib == "ISA=hippo" );
629  i = findBraceContent( "zod#[3]", bb, ib );
630  assert( i == 3 );
631  assert( bb == "zod#" );
632  assert( ib == "" );
633  i = findBraceContent( "zod##", bb, ib );
634  assert( i == ALLDATA );
635  assert( bb == "zod##" );
636  assert( ib == "" );
637 
638  bool ret = alignedSingleWildcardMatch( "a123456", "a123" );
639  assert( ret == true );
640  ret = alignedSingleWildcardMatch( "a123456", "1234" );
641  assert( ret == false );
642  ret = alignedSingleWildcardMatch( "a123456", "?1234" );
643  assert( ret == true );
644  ret = alignedSingleWildcardMatch( "a123456", "a????" );
645  assert( ret == true );
646  ret = alignedSingleWildcardMatch( "a123456", "??2??" );
647  assert( ret == true );
648  ret = alignedSingleWildcardMatch( "a123456", "??3??" );
649  assert( ret == false );
650  ret = alignedSingleWildcardMatch( "a1", "a?" );
651  assert( ret == true );
652 
653  unsigned int j = findWithSingleCharWildcard( "a12345678", 0, "a123" );
654  assert( j == 0 );
655  j = findWithSingleCharWildcard( "a12345678", 0, "123" );
656  assert( j == 1 );
657  j = findWithSingleCharWildcard( "a12345678", 0, "?123" );
658  assert( j == 0 );
659  j = findWithSingleCharWildcard( "a12345678", 0, "?23456?" );
660  assert( j == 1 );
661  j = findWithSingleCharWildcard( "a12345678", 0, "??6?" );
662  assert( j == 4 );
663 
664  Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
665  Id a1 = shell->doCreate( "Neutral", Id(), "a1", 1 );
666  Id c1 = shell->doCreate( "Arith", a1, "c1", 1 );
667  Id c2 = shell->doCreate( "Arith", a1, "c2", 1 );
668  Id c3 = shell->doCreate( "Arith", a1, "c3", 1 );
669  Id cIndex = shell->doCreate( "Neutral", a1, "c4", 1 );
670  Id c5 = shell->doCreate( "Neutral", a1, "Seg5_apical_1234_spine_234",1);
671 
672  ret = matchBeforeBrace( a1, "a1" );
673  assert( ret );
674  ret = matchBeforeBrace( a1, "a2" );
675  assert( ret == 0 );
676  ret = matchBeforeBrace( a1, "a?" );
677  assert( ret == 1 );
678  ret = matchBeforeBrace( a1, "?1" );
679  assert( ret == 1 );
680  ret = matchBeforeBrace( a1, "??" );
681  assert( ret == 1 );
682  ret = matchBeforeBrace( a1, "#" );
683  assert( ret == 1 );
684  ret = matchBeforeBrace( a1, "a#" );
685  assert( ret == 1 );
686  ret = matchBeforeBrace( a1, "#1" );
687  assert( ret == 1 );
688 
689  ret = matchBeforeBrace( cIndex, "c4" );
690  assert( ret == 1 );
691  ret = matchBeforeBrace( cIndex, "##" );
692  assert( ret == 1 );
693  ret = matchBeforeBrace( cIndex, "#4" );
694  assert( ret == 1 );
695  ret = matchBeforeBrace( cIndex, "#" );
696  assert( ret == 1 );
697  ret = matchBeforeBrace( cIndex, "?4" );
698  assert( ret == 1 );
699  ret = matchBeforeBrace( cIndex, "c1" );
700  assert( ret == 0 );
701  ret = matchBeforeBrace( cIndex, "c?" );
702  assert( ret == 1 );
703  ret = matchBeforeBrace( cIndex, "??" );
704  assert( ret == 1 );
705 
706  ret = matchBeforeBrace( c5, "Seg?_apical_#_spine_#" );
707  assert( ret == true );
708  ret = matchBeforeBrace( c5, "#Seg?_apical_#_spine_#" );
709  assert( ret == true );
710  ret = matchBeforeBrace( c5, "#?_apical_#_spine_#" );
711  assert( ret == true );
712  ret = matchBeforeBrace( c5, "#5_apical_#_spine_#" );
713  assert( ret == true );
714  ret = matchBeforeBrace( c5, "#e?5_apical_#_spine_#" );
715  assert( ret == true );
716  ret = matchBeforeBrace( c5, "#e5_apical_#_spine_#" );
717  assert( ret == false );
718  ret = matchBeforeBrace( c5, "#Seg5_apical_#_spine_#" );
719  assert( ret == true );
720  ret = matchBeforeBrace( c5, "#Seg#_apical_#_spine_#" );
721  assert( ret == true );
722  ret = matchBeforeBrace( c5, "Seg#_apical_#_spine_#" );
723  assert( ret == true );
724  ret = matchBeforeBrace( c5, "Seg#_a????l_#_spine_#" );
725  assert( ret == true );
726  ret = matchBeforeBrace( c5, "#?_a????l_#_spine_#" );
727  assert( ret == true );
728  ret = matchBeforeBrace( c5, "Seg?_a?????l_#_spine_#" );
729  assert( ret == false );
730  ret = matchBeforeBrace( c5, "Seg#_spine_#" );
731  assert( ret == true );
732 
733 
734  ret = matchInsideBrace( a1, "TYPE=Neutral" );
735  assert( ret );
736  ret = matchInsideBrace( a1, "TYPE==Neutral" );
737  assert( ret );
738  ret = matchInsideBrace( a1, "CLASS=Neutral" );
739  assert( ret );
740  ret = matchInsideBrace( a1, "ISA=Neutral" );
741  assert( ret );
742  ret = matchInsideBrace( a1, "CLASS=Neutral" );
743  assert( ret );
744  ret = matchInsideBrace( a1, "TYPE!=Channel" );
745  assert( ret );
746  ret = matchInsideBrace( a1, "CLASS!=Channel" );
747  assert( ret );
748  ret = matchInsideBrace( a1, "ISA!=Channel" );
749  assert( ret );
750  ret = matchInsideBrace( c3, "ISA==Neutral" ); // Everything is a Neutral
751  assert( ret );
752  ret = matchInsideBrace( c3, "ISA=Arith" );
753  assert( ret );
754  ret = matchInsideBrace( c3, "TYPE=membrane" );
755  assert( !ret );
756 
757  Field<double>::set( ObjId( c3, 0 ), "outputValue", 123.5 );
758  ret = matchInsideBrace( c3, "FIELD(outputValue)=123.5" );
759  assert( ret );
760  ret = matchInsideBrace( c3, "FIELD(outputValue)==123.5" );
761  assert( ret );
762  ret = matchInsideBrace( c3, "FIELD(outputValue)!=123.4" );
763  assert( ret );
764  ret = matchInsideBrace( c3, "FIELD(outputValue)>123.4" );
765  assert( ret );
766  ret = matchInsideBrace( c3, "FIELD(outputValue)<123.6" );
767  assert( ret );
768  ret = matchInsideBrace( c3, "FIELD(outputValue)>=123.4" );
769  assert( ret );
770  ret = matchInsideBrace( c3, "FIELD(outputValue)<=123.6" );
771  assert( ret );
772  ret = matchInsideBrace( c3, "FIELD(outputValue)>=123.5" );
773  assert( ret );
774  ret = matchInsideBrace( c3, "FIELD(outputValue)<=123.5" );
775  assert( ret );
776  ret = matchInsideBrace( c3, "FIELD(outputValue)==123.4" );
777  assert( !ret );
778  ret = matchInsideBrace( c3, "FIELD(outputValue)<123.4" );
779  assert( !ret );
780 
781 
782  ObjId el1[] = { ObjId(), a1, c1 };
783  wildcardTestFunc( el1, 3, "/,/a1,/a1/c1" );
784  ObjId el3[] = { c1, c2, c3, cIndex };
785  wildcardTestFunc( el3, 4, "/a1/c#" );
786  wildcardTestFunc( el3, 3, "/a1/c#[TYPE=Arith]" );
787 
788  ObjId el2[ 100 ];
789  for ( i = 0 ; i < 100; i++ )
790  {
791  char name[10];
792  sprintf( name, "ch%ld", i );
793  el2[i] = shell->doCreate( "Annotator", c1, name, 1 );
794  //el2[i] = Neutral::create( "HHChannel", name, c1->id(), Id::scratchId() );
795  Field< double >::set( ObjId( el2[i], 0 ), "z", i );
796  }
797 
798  wildcardTestFunc( el2, 100, "/a1/c1/##" );
799  wildcardTestFunc( el2, 100, "/a1/c1/#" );
800 
801  wildcardTestFunc( el2, 0, "/a1/##[TYPE=IntFire]" );
802  wildcardTestFunc( el2, 100, "/a1/##[TYPE=Annotator]" );
803  wildcardTestFunc( el2, 50, "/a1/c1/##[][FIELD(z)<50]" );
804 
805  // Here we set up some thoroughly ugly nesting.
806  // Note the sequence: The wildcarding goes depth first,
807  // and then in order of creation.
808  ObjId el4[12];
809  i = 0;
810  el4[i] = shell->doCreate( "IntFire", el2[0], "g0", 1 );
811  ++i;
812  el4[i] = shell->doCreate( "IntFire", el2[1], "g1", 1 );
813  ++i;
814  el4[i] = shell->doCreate( "IntFire", el2[1], "g2", 1 );
815  ++i;
816  el4[i] = shell->doCreate( "IntFire", el2[2], "g3", 1 );
817  ++i;
818  el4[i] = shell->doCreate( "IntFire", el2[2], "g4", 1 );
819  ++i;
820  el4[i] = shell->doCreate( "IntFire", el2[4], "g5", 1 );
821  ++i;
822  el4[i] = shell->doCreate( "IntFire", el2[5], "g6", 1 );
823  ++i;
824  el4[i] = shell->doCreate( "IntFire", el2[6], "g7", 1 );
825  ++i;
826  el4[i] = shell->doCreate( "IntFire", el2[1], "g8", 1 );
827  ++i;
828  el4[i] = shell->doCreate( "IntFire", el2[1], "g9", 1 );
829  ++i;
830  el4[i] = shell->doCreate( "IntFire", c2, "g10", 1 );
831  ++i;
832  el4[i] = shell->doCreate( "IntFire", c3, "g11", 1 );
833  ++i;
834 
835  wildcardTestFunc( el4, 12, "/a1/##[TYPE=IntFire]" );
836  wildcardTestFunc( el4, 12, "/##[TYPE=IntFire]" );
837 
838  // Here I test wildcards with array Elements.
839  Id x = shell->doCreate( "Arith", a1, "x", 5 );
840  Id y = shell->doCreate( "Arith", ObjId( x, 2 ), "y", 5 );
841  Id z = shell->doCreate( "Arith", ObjId( y, 3 ), "z", 5 );
842  vector< ObjId > vec;
843  simpleWildcardFind( "/a1/x[]/##", vec );
844  assert( vec.size() == 10 );
845  vec.clear();
846  simpleWildcardFind( "/a1/x[]/##,/a1/x[]", vec );
847  assert( vec.size() == 15 );
848  vec.clear();
849  simpleWildcardFind( "/a1/x[2]/y[]", vec );
850  assert( vec.size() == 5 );
851 
852  // Here I test exclusive wildcards, should NOT get additional terms.
853  Id xyzzy = shell->doCreate( "Arith", a1, "xyzzy", 5 );
854  Id xdotp = shell->doCreate( "Arith", a1, "x.P", 5 );
855  vec.clear();
856  simpleWildcardFind( "/a1/x", vec );
857  assert( vec.size() == 1 );
858  vec.clear();
859  simpleWildcardFind( "/a1/x[0]", vec );
860  assert( vec.size() == 1 );
861  vec.clear();
862  simpleWildcardFind( "/a1/x[2]", vec );
863  assert( vec.size() == 1 );
864  vec.clear();
865  simpleWildcardFind( "/a1/x[]", vec );
866  assert( vec.size() == 5 );
867 
868  //a1.destroy();
869  shell->doDelete( a1 );
870  cout << "." << flush;
871 }
char * data() const
Definition: Eref.cpp:41
int simpleWildcardFind(const string &path, vector< ObjId > &ret)
Definition: Wildcard.cpp:137
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool alignedSingleWildcardMatch(const string &name, const string &wild)
Definition: Wildcard.cpp:383
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
void wildcardTestFunc(ObjId *elist, unsigned int ne, const string &path)
Definition: Wildcard.cpp:567
bool matchBeforeBrace(ObjId id, const string &wild)
Definition: Wildcard.cpp:432
static bool matchInsideBrace(ObjId id, const string &inside)
Definition: Wildcard.cpp:322
unsigned int findWithSingleCharWildcard(const string &name, unsigned int start, const string &wild)
Definition: Wildcard.cpp:405
static char name[]
Definition: mfield.cpp:401
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static unsigned int findBraceContent(const string &path, string &beforeBrace, string &insideBrace)
Definition: Wildcard.cpp:243
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void verifyKids ( Id  f1,
Id  f2a,
Id  f2b,
Id  f3,
Id  f4a,
Id  f4b 
)

Utility function to check a commonly used tree structure.

Definition at line 266 of file testShell.cpp.

References Neutral::buildTree(), Neutral::children(), Eref::data(), and Id::eref().

Referenced by testChildren(), testCopy(), and testMove().

267 {
268  Neutral* f1Data = reinterpret_cast< Neutral* >( f1.eref().data() );
269  vector< Id > kids;
270  f1Data->children( f1.eref(), kids );
271  assert( kids.size() == 2 );
272  assert( kids[0] == f2a );
273  assert( kids[1] == f2b );
274 
275  vector< Id > tree;
276 
277  // Neutral::buildTree is depth-first.
278  int num = f1Data->buildTree( f1.eref(), tree );
279  assert( num == 6 );
280  assert( tree.size() == 6 );
281  assert( tree[5] == f1 );
282  assert( tree[3] == f2a );
283  assert( tree[2] == f3 );
284  assert( tree[0] == f4a );
285  assert( tree[1] == f4b );
286  assert( tree[4] == f2b );
287 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
static void children(const Eref &e, vector< Id > &ret)
Definition: Neutral.cpp:342
unsigned int buildTree(const Eref &e, vector< Id > &tree) const
Definition: Neutral.cpp:583

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const bool TEST_WARNING = false

Definition at line 25 of file testShell.cpp.

Referenced by testChildren(), and testTreeTraversal().