From: <net...@us...> - 2003-04-29 09:57:05
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv30133/src/rftaparser Modified Files: UnparsedDeclarationMutatorTest.h UnparsedDeclarationMutatorTest.cpp Log Message: -- corrected "UnparsedDeclarationMutator" to be a real Mutator that can be used by MaxLODMutator Index: UnparsedDeclarationMutatorTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UnparsedDeclarationMutatorTest.h 28 Apr 2003 20:36:46 -0000 1.2 --- UnparsedDeclarationMutatorTest.h 29 Apr 2003 09:57:01 -0000 1.3 *************** *** 42,45 **** --- 42,46 ---- CPPUNIT_TEST( testStructTypedef ); CPPUNIT_TEST( testTypedefDeclaration ); + CPPUNIT_TEST( testOperatorMember ); /* class member extensions */ CPPUNIT_TEST( testMemberPure ); *************** *** 86,89 **** --- 87,91 ---- void testMemberConstInit(); void testStructBitfield(); + void testOperatorMember(); private: Index: UnparsedDeclarationMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UnparsedDeclarationMutatorTest.cpp 28 Apr 2003 20:36:47 -0000 1.5 --- UnparsedDeclarationMutatorTest.cpp 29 Apr 2003 09:57:01 -0000 1.6 *************** *** 15,19 **** #include <boost/format.hpp> - namespace Refactoring { --- 15,18 ---- *************** *** 24,27 **** --- 23,27 ---- const std::string DECLARATOR = "DECLARATOR"; const std::string SPECIFIERLIST = "SPECIFIERLIST"; + const std::string FUNCTIONBODY = "FUNCTIONBODY"; namespace Testing *************** *** 31,38 **** { SourceASTNodePtr sourceNode = SourceASTNode::create( source, source ); ! ParseContext context( sourceNode ); ! ! // simulate statement level parsing ! ASTNodePtr statement = ASTNode::create( ASTNodeTypes::declarationOrExpression, sourceNode, --- 31,37 ---- { SourceASTNodePtr sourceNode = SourceASTNode::create( source, source ); ! ParseContext context( sourceNode ); ! ! ASTNodePtr decl = ASTNode::create( ASTNodeTypes::declarationOrExpression, sourceNode, *************** *** 40,53 **** source.length(), sourceNode ); ! context.addNode( statement ); // do variable declaration parsing ! UnparsedDeclarationMutator mutator( context, ! statement, ! sourceNode ); ! ! CppUnit::Message message( "mutator failed", ! "Source:\n" + source ); ! CppUnit::Asserter::failIf( !mutator.tryMutate(), message, sourceLine ); return sourceNode; --- 39,47 ---- source.length(), sourceNode ); ! context.addNode( decl ); // do variable declaration parsing ! UnparsedDeclarationMutator mutator; ! mutator.mutate(decl,sourceNode); return sourceNode; *************** *** 198,202 **** Testing::KeyedString source; source.addKeyed(SPECIFIER , "int" ) << " "; ! source.addKeyed(DECLARATOR, "fct(int p1, unsigned int p2, typename tp<int> p3)" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source.asString() ); --- 192,196 ---- Testing::KeyedString source; source.addKeyed(SPECIFIER , "int" ) << " "; ! source.addKeyed(DECLARATOR, "fct(int p1, unsigned int p2, typename tp<int> p3) const" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source.asString() ); *************** *** 218,221 **** --- 212,216 ---- { Testing::KeyedString source; + source.addKeyed(SPECIFIER,"const") << " "; source.setKeyStart(SPECIFIER) << "class x {"; source.addKeyed("CLASS-BODY" , " public: int x() { } " ) << "}" ; *************** *** 231,235 **** // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(0); RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier ); --- 226,230 ---- // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(1); RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier ); *************** *** 707,710 **** --- 702,723 ---- source.addKeyed(DECLARATOR, "bit0: 1 + 2" ) << ","; source.addKeyed(DECLARATOR, "bit1: 25" ) << ";"; + + SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); + ASTNodePtr node = sourceAST->getChildAt(0); + + // check AST: + RFTA_ASSERT_DECLARATION( source, sourceAST ); + + // check declarator types: + RFTA_ASSERT_NODE_TYPE( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator); + } + + void + UnparsedDeclarationMutatorTest::testOperatorMember() + { + Testing::KeyedString source; + source.addKeyed(SPECIFIER , "inline" ) << " "; + source.addKeyed(DECLARATOR, "KeyedString::operator std::string() const" ) << " "; + source.addKeyed(FUNCTIONBODY,"{ return sequence_; }"); SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); |